Part of OpenBSD porting
This commit is contained in:
parent
139ec0d628
commit
7265273d1a
@ -203,9 +203,9 @@ fi
|
|||||||
|
|
||||||
|
|
||||||
dnl
|
dnl
|
||||||
dnl For FreeBSD we need -pthread for gcc and don't need libpthread
|
dnl For FreeBSD and OpenBSD we need -pthread for gcc and don't need libpthread
|
||||||
dnl
|
dnl
|
||||||
if test "$SYSTEM" = "FreeBSD"; then
|
if test "$SYSTEM" = "FreeBSD" || test "$SYSTEM" = "OpenBSD"; then
|
||||||
CFLAGS="-pthread $CFLAGS"
|
CFLAGS="-pthread $CFLAGS"
|
||||||
else
|
else
|
||||||
AC_CHECK_LIB(pthread,pthread_create,result=yes,result=no)
|
AC_CHECK_LIB(pthread,pthread_create,result=yes,result=no)
|
||||||
|
@ -2018,7 +2018,6 @@ struct _route {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern char SigName[32][16];
|
extern char SigName[32][16];
|
||||||
|
|
||||||
|
|
||||||
|
@ -122,7 +122,11 @@ extern int disk_run; /* Disk watch running */
|
|||||||
/*
|
/*
|
||||||
* Global thread vaiables
|
* Global thread vaiables
|
||||||
*/
|
*/
|
||||||
pthread_t p_thread[NUM_THREADS]; /* thread's structure */
|
pthread_t pt_ping;
|
||||||
|
pthread_t pt_command;
|
||||||
|
pthread_t pt_disk;
|
||||||
|
pthread_t pt_scheduler;
|
||||||
|
// pthread_t p_thread[NUM_THREADS]; /* thread's structure */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -946,7 +950,11 @@ void start_scheduler(void)
|
|||||||
char *cmd = NULL;
|
char *cmd = NULL;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
if (nodaemon)
|
||||||
|
printf("init fidonet\n");
|
||||||
InitFidonet();
|
InitFidonet();
|
||||||
|
if (nodaemon)
|
||||||
|
printf("done\n");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Registrate this server for mbmon in slot 0.
|
* Registrate this server for mbmon in slot 0.
|
||||||
@ -958,6 +966,8 @@ void start_scheduler(void)
|
|||||||
strcpy(reginfo[0].city, "localhost");
|
strcpy(reginfo[0].city, "localhost");
|
||||||
strcpy(reginfo[0].doing, "Start");
|
strcpy(reginfo[0].doing, "Start");
|
||||||
reginfo[0].started = time(NULL);
|
reginfo[0].started = time(NULL);
|
||||||
|
if (nodaemon)
|
||||||
|
printf("reginfo filled\n");
|
||||||
|
|
||||||
Processing = TRUE;
|
Processing = TRUE;
|
||||||
TouchSema((char *)"mbtask.last");
|
TouchSema((char *)"mbtask.last");
|
||||||
@ -980,6 +990,8 @@ void start_scheduler(void)
|
|||||||
WriteError("$Can't bind socket %s", spath);
|
WriteError("$Can't bind socket %s", spath);
|
||||||
die(MBERR_INIT_ERROR);
|
die(MBERR_INIT_ERROR);
|
||||||
}
|
}
|
||||||
|
if (nodaemon)
|
||||||
|
printf("sockets created\n");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The flag masterinit is set if a new config.data is created, this
|
* The flag masterinit is set if a new config.data is created, this
|
||||||
@ -996,30 +1008,37 @@ void start_scheduler(void)
|
|||||||
masterinit = FALSE;
|
masterinit = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (nodaemon)
|
||||||
|
printf("init nodelists\n");
|
||||||
|
|
||||||
initnl();
|
initnl();
|
||||||
sem_set((char *)"scanout", TRUE);
|
sem_set((char *)"scanout", TRUE);
|
||||||
if (!TCFG.max_tcp && !pots_lines && !isdn_lines) {
|
if (!TCFG.max_tcp && !pots_lines && !isdn_lines) {
|
||||||
Syslog('?', "WARNING: this system cannot connect to other systems, check setup");
|
Syslog('?', "WARNING: this system cannot connect to other systems, check setup");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (nodaemon)
|
||||||
|
printf("creating threads\n");
|
||||||
/*
|
/*
|
||||||
* Install the threads that do the real work.
|
* Install the threads that do the real work.
|
||||||
*/
|
*/
|
||||||
if ((rc = pthread_create(&p_thread[0], NULL, (void (*))ping_thread, NULL))) {
|
if ((rc = pthread_create(&pt_ping, NULL, /* (void (*)) */ ping_thread, NULL))) {
|
||||||
WriteError("$pthread_create ping_thread rc=%d", rc);
|
WriteError("$pthread_create ping_thread rc=%d", rc);
|
||||||
die(SIGTERM);
|
die(SIGTERM);
|
||||||
} else if ((rc = pthread_create(&p_thread[1], NULL, (void (*))cmd_thread, NULL))) {
|
} else if ((rc = pthread_create(&pt_command, NULL, (void (*))cmd_thread, NULL))) {
|
||||||
WriteError("$pthread_create cmd_thread rc=%d", rc);
|
WriteError("$pthread_create cmd_thread rc=%d", rc);
|
||||||
die(SIGTERM);
|
die(SIGTERM);
|
||||||
} else if ((rc = pthread_create(&p_thread[2], NULL, (void (*))disk_thread, NULL))) {
|
} else if ((rc = pthread_create(&pt_disk, NULL, (void (*))disk_thread, NULL))) {
|
||||||
WriteError("$pthread_create disk_thread rc=%d", rc);
|
WriteError("$pthread_create disk_thread rc=%d", rc);
|
||||||
die(SIGTERM);
|
die(SIGTERM);
|
||||||
} else if ((rc = pthread_create(&p_thread[3], NULL, (void (*))scheduler, NULL))) {
|
} else if ((rc = pthread_create(&pt_scheduler, NULL, (void (*))scheduler, NULL))) {
|
||||||
WriteError("$pthread_create scheduler rc=%d", rc);
|
WriteError("$pthread_create scheduler rc=%d", rc);
|
||||||
die(SIGTERM);
|
die(SIGTERM);
|
||||||
} else {
|
} else {
|
||||||
Syslog('+', "All threads installed");
|
Syslog('+', "All threads installed");
|
||||||
}
|
}
|
||||||
|
if (nodaemon)
|
||||||
|
printf("threads installed\n");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sleep until we die
|
* Sleep until we die
|
||||||
@ -1043,7 +1062,7 @@ void *scheduler(void)
|
|||||||
char *cmd = NULL, opts[41], port[21];
|
char *cmd = NULL, opts[41], port[21];
|
||||||
static char doing[32];
|
static char doing[32];
|
||||||
time_t now;
|
time_t now;
|
||||||
struct tm *tm, *utm;
|
struct tm tm, utm;
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
#endif
|
#endif
|
||||||
@ -1127,15 +1146,20 @@ void *scheduler(void)
|
|||||||
* Reload configuration data if some file is changed.
|
* Reload configuration data if some file is changed.
|
||||||
*/
|
*/
|
||||||
now = time(NULL);
|
now = time(NULL);
|
||||||
tm = localtime(&now);
|
#if defined(__OpenBSD__)
|
||||||
utm = gmtime(&now);
|
localtime_r(&now, &tm);
|
||||||
if (tm->tm_min != olddo) {
|
gmtime_r(&now, &utm);
|
||||||
|
#else
|
||||||
|
tm = *localtime(&now);
|
||||||
|
utm = *gmtime(&now);
|
||||||
|
#endif
|
||||||
|
if (tm.tm_min != olddo) {
|
||||||
/*
|
/*
|
||||||
* Each minute we execute this part
|
* Each minute we execute this part
|
||||||
*/
|
*/
|
||||||
if (tosswait)
|
if (tosswait)
|
||||||
tosswait--;
|
tosswait--;
|
||||||
olddo = tm->tm_min;
|
olddo = tm.tm_min;
|
||||||
TouchSema((char *)"mbtask.last");
|
TouchSema((char *)"mbtask.last");
|
||||||
if (file_time(tcfgfn) != tcfg_time) {
|
if (file_time(tcfgfn) != tcfg_time) {
|
||||||
Syslog('+', "Task configuration changed, reloading");
|
Syslog('+', "Task configuration changed, reloading");
|
||||||
@ -1163,8 +1187,8 @@ void *scheduler(void)
|
|||||||
/*
|
/*
|
||||||
* If the next event time is reached, rescan the outbound
|
* If the next event time is reached, rescan the outbound
|
||||||
*/
|
*/
|
||||||
if ((utm->tm_hour == nxt_hour) && (utm->tm_min == nxt_min)) {
|
if ((utm.tm_hour == nxt_hour) && (utm.tm_min == nxt_min)) {
|
||||||
Syslog('+', "It is now %02d:%02d UTC, starting new event", utm->tm_hour, utm->tm_min);
|
Syslog('+', "It is now %02d:%02d UTC, starting new event", utm.tm_hour, utm.tm_min);
|
||||||
sem_set((char *)"scanout", TRUE);
|
sem_set((char *)"scanout", TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1188,8 +1212,8 @@ void *scheduler(void)
|
|||||||
* Check Pause Timer, make sure it's only checked
|
* Check Pause Timer, make sure it's only checked
|
||||||
* once each second. Also do pingcheck.
|
* once each second. Also do pingcheck.
|
||||||
*/
|
*/
|
||||||
if (tm->tm_sec != oldsec) {
|
if (tm.tm_sec != oldsec) {
|
||||||
oldsec = tm->tm_sec;
|
oldsec = tm.tm_sec;
|
||||||
if (ptimer)
|
if (ptimer)
|
||||||
ptimer--;
|
ptimer--;
|
||||||
}
|
}
|
||||||
@ -1274,12 +1298,12 @@ void *scheduler(void)
|
|||||||
|
|
||||||
} /* if (Processing) */
|
} /* if (Processing) */
|
||||||
|
|
||||||
if ((tm->tm_sec / SLOWRUN) != oldmin) {
|
if ((tm.tm_sec / SLOWRUN) != oldmin) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These tasks run once per 20 seconds.
|
* These tasks run once per 20 seconds.
|
||||||
*/
|
*/
|
||||||
oldmin = tm->tm_sec / SLOWRUN;
|
oldmin = tm.tm_sec / SLOWRUN;
|
||||||
|
|
||||||
if (Processing) {
|
if (Processing) {
|
||||||
|
|
||||||
@ -1410,18 +1434,16 @@ int main(int argc, char **argv)
|
|||||||
* but that's live. This daemon should only be stopped by SIGTERM.
|
* but that's live. This daemon should only be stopped by SIGTERM.
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < NSIG; i++) {
|
for (i = 0; i < NSIG; i++) {
|
||||||
if ((i == SIGHUP) || (i == SIGBUS) || (i == SIGILL) || (i == SIGSEGV))
|
if ((i == SIGHUP) || (i == SIGPIPE) || (i == SIGBUS) || (i == SIGILL) || (i == SIGSEGV))
|
||||||
signal(i, (void (*))die);
|
signal(i, (void (*))die);
|
||||||
else if ((i == SIGINT) || (i == SIGTERM))
|
else if ((i == SIGINT) || (i == SIGTERM))
|
||||||
signal(i, (void (*))start_shutdown);
|
signal(i, (void (*))start_shutdown);
|
||||||
else if (i == SIGCHLD)
|
else if (i == SIGCHLD)
|
||||||
signal(i, SIG_DFL);
|
signal(i, SIG_DFL);
|
||||||
else if ((i != SIGKILL) && (i != SIGSTOP))
|
// else if ((i != SIGKILL) && (i != SIGSTOP))
|
||||||
signal(i, SIG_IGN);
|
// signal(i, SIG_IGN);
|
||||||
}
|
}
|
||||||
|
|
||||||
init_pingsocket();
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Secret undocumented startup switch, ie: no help available.
|
* Secret undocumented startup switch, ie: no help available.
|
||||||
*/
|
*/
|
||||||
@ -1429,6 +1451,8 @@ int main(int argc, char **argv)
|
|||||||
nodaemon = TRUE;
|
nodaemon = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
init_pingsocket();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* mbtask is setuid root, drop privileges to user mbse.
|
* mbtask is setuid root, drop privileges to user mbse.
|
||||||
* This will stay forever like this, no need to become
|
* This will stay forever like this, no need to become
|
||||||
@ -1463,10 +1487,16 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
sprintf(cfgfn, "%s/etc/config.data", getenv("MBSE_ROOT"));
|
sprintf(cfgfn, "%s/etc/config.data", getenv("MBSE_ROOT"));
|
||||||
load_maincfg();
|
load_maincfg();
|
||||||
|
if (nodaemon)
|
||||||
|
printf("main config loaded\n");
|
||||||
|
|
||||||
mypid = getpid();
|
mypid = getpid();
|
||||||
|
if (nodaemon)
|
||||||
|
printf("my pid is %d\n", mypid);
|
||||||
|
|
||||||
Syslog(' ', " ");
|
Syslog(' ', " ");
|
||||||
Syslog(' ', "MBTASK v%s", VERSION);
|
Syslog(' ', "MBTASK v%s", VERSION);
|
||||||
|
|
||||||
if (nodaemon)
|
if (nodaemon)
|
||||||
Syslog('+', "Starting in no-daemon mode");
|
Syslog('+', "Starting in no-daemon mode");
|
||||||
|
|
||||||
@ -1496,6 +1526,7 @@ int main(int argc, char **argv)
|
|||||||
* For debugging, run in foreground mode
|
* For debugging, run in foreground mode
|
||||||
*/
|
*/
|
||||||
mypid = getpid();
|
mypid = getpid();
|
||||||
|
printf("init complete, starting scheduler ...\n");
|
||||||
start_scheduler();
|
start_scheduler();
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
|
@ -116,13 +116,17 @@ void set_next(int, int);
|
|||||||
void set_next(int hour, int min)
|
void set_next(int hour, int min)
|
||||||
{
|
{
|
||||||
time_t now;
|
time_t now;
|
||||||
struct tm *etm;
|
struct tm etm;
|
||||||
int uhour, umin;
|
int uhour, umin;
|
||||||
|
|
||||||
now = time(NULL);
|
now = time(NULL);
|
||||||
|
#if defined(__OpenBSD__)
|
||||||
|
gmtime_r(&now, &etm);
|
||||||
|
#else
|
||||||
etm = gmtime(&now);
|
etm = gmtime(&now);
|
||||||
uhour = etm->tm_hour; /* For some reason, these intermediate integers are needed */
|
#endif
|
||||||
umin = etm->tm_min;
|
uhour = etm.tm_hour; /* For some reason, these intermediate integers are needed */
|
||||||
|
umin = etm.tm_min;
|
||||||
|
|
||||||
if ((hour > uhour) || ((hour == uhour) && (min > umin))) {
|
if ((hour > uhour) || ((hour == uhour) && (min > umin))) {
|
||||||
if (hour < nxt_hour) {
|
if (hour < nxt_hour) {
|
||||||
@ -257,7 +261,7 @@ int outstat()
|
|||||||
struct _alist *tmp, *old;
|
struct _alist *tmp, *old;
|
||||||
char digit[6], flstr[13], *temp, as[6], be[6], utc[6], flavor, *temp2;
|
char digit[6], flstr[13], *temp, as[6], be[6], utc[6], flavor, *temp2;
|
||||||
time_t now;
|
time_t now;
|
||||||
struct tm *tm;
|
struct tm tm;
|
||||||
int uhour, umin, thour, tmin;
|
int uhour, umin, thour, tmin;
|
||||||
pp_list *tpl;
|
pp_list *tpl;
|
||||||
faddr *fa;
|
faddr *fa;
|
||||||
@ -277,9 +281,13 @@ int outstat()
|
|||||||
itnmask = (*tmpm)->mask;
|
itnmask = (*tmpm)->mask;
|
||||||
}
|
}
|
||||||
now = time(NULL);
|
now = time(NULL);
|
||||||
tm = gmtime(&now); /* UTC time */
|
#if defined(__OpenBSD__)
|
||||||
uhour = tm->tm_hour;
|
gmtime_r(&now, &tm);
|
||||||
umin = tm->tm_min;
|
#else
|
||||||
|
tm = *gmtime(&now); /* UTC time */
|
||||||
|
#endif
|
||||||
|
uhour = tm.tm_hour;
|
||||||
|
umin = tm.tm_min;
|
||||||
sprintf(utc, "%02d:%02d", uhour, umin);
|
sprintf(utc, "%02d:%02d", uhour, umin);
|
||||||
Syslog('+', "Scanning outbound at %s UTC.", utc);
|
Syslog('+', "Scanning outbound at %s UTC.", utc);
|
||||||
nxt_hour = 24;
|
nxt_hour = 24;
|
||||||
|
@ -329,7 +329,7 @@ void init_pingsocket(void)
|
|||||||
/*
|
/*
|
||||||
* Ping thread
|
* Ping thread
|
||||||
*/
|
*/
|
||||||
void *ping_thread(void)
|
void *ping_thread(void *dummy)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
static int pingnr, pingresult[2];
|
static int pingnr, pingresult[2];
|
||||||
@ -337,6 +337,8 @@ void *ping_thread(void)
|
|||||||
static time_t pingsend;
|
static time_t pingsend;
|
||||||
time_t now;
|
time_t now;
|
||||||
|
|
||||||
|
printf("Start ping thread\n");
|
||||||
|
|
||||||
Syslog('+', "Starting ping thread");
|
Syslog('+', "Starting ping thread");
|
||||||
pingresult[1] = pingresult[2] = FALSE;
|
pingresult[1] = pingresult[2] = FALSE;
|
||||||
pingnr = 2;
|
pingnr = 2;
|
||||||
|
@ -11,6 +11,6 @@
|
|||||||
#define SET_SOCKA_LEN4(socka)
|
#define SET_SOCKA_LEN4(socka)
|
||||||
|
|
||||||
void init_pingsocket(void);
|
void init_pingsocket(void);
|
||||||
void *ping_thread(void);
|
void *ping_thread(void*);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
* Signal handler signal names.
|
* Signal handler signal names.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef __i386__
|
#if defined(__i386__)
|
||||||
|
|
||||||
char SigName[32][16] = { "NOSIGNAL",
|
char SigName[32][16] = { "NOSIGNAL",
|
||||||
"SIGHUP", "SIGINT", "SIGQUIT", "SIGILL",
|
"SIGHUP", "SIGINT", "SIGQUIT", "SIGILL",
|
||||||
@ -48,11 +48,10 @@ char SigName[32][16] = { "NOSIGNAL",
|
|||||||
"SIGXFSZ", "SIGVTALRM", "SIGPROF", "SIGWINCH",
|
"SIGXFSZ", "SIGVTALRM", "SIGPROF", "SIGWINCH",
|
||||||
"SIGIO", "SIGPWR", "SIGUNUSED"};
|
"SIGIO", "SIGPWR", "SIGUNUSED"};
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __PPC__
|
#elif defined(__PPC__)
|
||||||
|
|
||||||
char SigName[32][16] = { "NOSIGNAL",
|
char SgName[32][16] = { "NOSIGNAL",
|
||||||
"SIGHUP", "SIGINT", "SIGQUIT", "SIGILL",
|
"SIGHUP", "SIGINT", "SIGQUIT", "SIGILL",
|
||||||
"SIGTRAP", "SIGIOT", "SIGBUS", "SIGFPE",
|
"SIGTRAP", "SIGIOT", "SIGBUS", "SIGFPE",
|
||||||
"SIGKILL", "SIGUSR1", "SIGSEGV", "SIGUSR2",
|
"SIGKILL", "SIGUSR1", "SIGSEGV", "SIGUSR2",
|
||||||
@ -62,11 +61,10 @@ char SigName[32][16] = { "NOSIGNAL",
|
|||||||
"SIGXFSZ", "SIGVTALRM", "SIGPROF", "SIGWINCH",
|
"SIGXFSZ", "SIGVTALRM", "SIGPROF", "SIGWINCH",
|
||||||
"SIGIO", "SIGPWR", "SIGUNUSED"};
|
"SIGIO", "SIGPWR", "SIGUNUSED"};
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __sparc__
|
#elif defined(__sparc__)
|
||||||
|
|
||||||
char SigName[32][16] = { "NOSIGNAL",
|
char SgName[32][16] = { "NOSIGNAL",
|
||||||
"SIGHUP", "SIGINT", "SIGQUIT", "SIGILL",
|
"SIGHUP", "SIGINT", "SIGQUIT", "SIGILL",
|
||||||
"SIGTRAP", "SIGIOT", "SIGEMT", "SIGFPE",
|
"SIGTRAP", "SIGIOT", "SIGEMT", "SIGFPE",
|
||||||
"SIGKILL", "SIGBUS", "SIGSEGV", "SIGSYS",
|
"SIGKILL", "SIGBUS", "SIGSEGV", "SIGSYS",
|
||||||
@ -75,11 +73,10 @@ char SigName[32][16] = { "NOSIGNAL",
|
|||||||
"SIGTTIN", "SIGTTOU", "SIGIO", "SIGXCPU",
|
"SIGTTIN", "SIGTTOU", "SIGIO", "SIGXCPU",
|
||||||
"SIGXFSZ", "SIGVTALRM", "SIGPROF", "SIGWINCH",
|
"SIGXFSZ", "SIGVTALRM", "SIGPROF", "SIGWINCH",
|
||||||
"SIGLOST", "SIGUSR1", "SIGUSR2"};
|
"SIGLOST", "SIGUSR1", "SIGUSR2"};
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __alpha__
|
#elif defined(__alpha__)
|
||||||
|
|
||||||
char SigName[32][16] = { "NOSIGNAL",
|
char SgName[32][16] = { "NOSIGNAL",
|
||||||
"SIGHUP", "SIGINT", "SIGQUIT", "SIGILL",
|
"SIGHUP", "SIGINT", "SIGQUIT", "SIGILL",
|
||||||
"SIGTRAP", "SIGABRT", "SIGEMT", "SIGFPE",
|
"SIGTRAP", "SIGABRT", "SIGEMT", "SIGFPE",
|
||||||
"SIGKILL", "SIGBUS", "SIGSEGV", "SIGSYS",
|
"SIGKILL", "SIGBUS", "SIGSEGV", "SIGSYS",
|
||||||
@ -89,20 +86,18 @@ char SigName[32][16] = { "NOSIGNAL",
|
|||||||
"SIGXFSZ", "SIGVTALRM", "SIGPROF", "SIGWINCH",
|
"SIGXFSZ", "SIGVTALRM", "SIGPROF", "SIGWINCH",
|
||||||
"SIGINFO", "SIGUSR1", "SIGUSR2"};
|
"SIGINFO", "SIGUSR1", "SIGUSR2"};
|
||||||
|
|
||||||
|
#elif defined(__hppa__)
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __hppa__
|
|
||||||
|
|
||||||
char SigName[32][16] = { "NOSIGNAL",
|
char SigName[32][16] = { "NOSIGNAL",
|
||||||
"SIGHUP", "SIGINT", "SIGQUIT", "SIGILL",
|
"SIGHUP", "SIGINT", "SIGQUIT", "SIGILL",
|
||||||
"SIGTRAP", "SIGABRT", "SIGEMT", "SIGFPE",
|
"SIGTRAP", "SIGABRT", "SIGEMT", "SIGFPE",
|
||||||
"SIGKILL", "SIGBUS", "SIGSEGV", "SIGSYS",
|
"SIGKILL", "SIGBUS", "SIGSEGV", "SIGSYS",
|
||||||
"SIGPIPE", "SIGALRM", "SIGTERM", "SIGUSR1",
|
"SIGPIPE", "SIGALRM", "SIGTERM", "SIGURG",
|
||||||
"SIGUSR2", "SIGCHLD", "SIGPWR", "SIGVTALRM",
|
"SIGSTOP", "SIGTSTP", "SIGCONT", "SIGCHLD",
|
||||||
"SIGPROF", "SIGIO", "SIGWINCH", "SIGSTOP",
|
"SIGTTIN", "SIGTTOU", "SIGWIO", "SIGXCPU",
|
||||||
"SIGTSTP", "SIGCONT", "SIGTTIN", "SIGTTOU",
|
"SIGXFSZ", "SIGVTALRM", "SIGPROF", "SIGWINCH",
|
||||||
"SIGURG", "SIGLOST", "SIGUNUSED"};
|
"SIGINFO", "SIGUSR1", "SIGUSR2"};
|
||||||
|
|
||||||
|
#else
|
||||||
|
#error "Cannot make SigName array on this platform"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
|
||||||
char SigName[32][16];
|
// char SigName[32][16];
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -143,19 +143,27 @@ void status_write(void);
|
|||||||
void status_write(void)
|
void status_write(void)
|
||||||
{
|
{
|
||||||
int d, stat_fd, yday;
|
int d, stat_fd, yday;
|
||||||
struct tm *ttm;
|
struct tm ttm;
|
||||||
time_t temp;
|
time_t temp;
|
||||||
|
|
||||||
|
#if defined(__OpenBSD)
|
||||||
temp = time(NULL);
|
temp = time(NULL);
|
||||||
ttm = localtime(&temp);
|
localtime_r(&temp, &ttm);
|
||||||
yday = ttm->tm_yday;
|
yday = ttm.tm_yday;
|
||||||
|
temp = status.daily;
|
||||||
|
localtime_r(&temp, &ttm);
|
||||||
|
#else
|
||||||
|
temp = time(NULL);
|
||||||
|
ttm = *localtime(&temp);
|
||||||
|
yday = ttm.tm_yday;
|
||||||
temp = status.daily; // On a Sparc, first put the time in temp, then pass it to locattime.
|
temp = status.daily; // On a Sparc, first put the time in temp, then pass it to locattime.
|
||||||
ttm = localtime(&temp);
|
ttm = *localtime(&temp);
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we passed to the next day, zero the today counters
|
* If we passed to the next day, zero the today counters
|
||||||
*/
|
*/
|
||||||
if (yday != ttm->tm_yday) {
|
if (yday != ttm.tm_yday) {
|
||||||
Syslog('+', "Last days statistics:");
|
Syslog('+', "Last days statistics:");
|
||||||
Syslog('+', "Total clients : %lu", status.today.tot_clt);
|
Syslog('+', "Total clients : %lu", status.today.tot_clt);
|
||||||
Syslog('+', "Peak clients : %lu", status.today.peak_clt);
|
Syslog('+', "Peak clients : %lu", status.today.peak_clt);
|
||||||
@ -201,13 +209,17 @@ void status_write(void)
|
|||||||
*/
|
*/
|
||||||
int get_zmh()
|
int get_zmh()
|
||||||
{
|
{
|
||||||
struct tm *l_date;
|
struct tm l_date;
|
||||||
char sstime[6];
|
char sstime[6];
|
||||||
time_t Now;
|
time_t Now;
|
||||||
|
|
||||||
Now = time(NULL);
|
Now = time(NULL);
|
||||||
l_date = gmtime(&Now);
|
#if defined(__OpenBSD__)
|
||||||
sprintf(sstime, "%02d:%02d", l_date->tm_hour, l_date->tm_min);
|
gmtime_r(&Now, &l_date);
|
||||||
|
#else
|
||||||
|
l_date = *gmtime(&Now);
|
||||||
|
#endif
|
||||||
|
sprintf(sstime, "%02d:%02d", l_date.tm_hour, l_date.tm_min);
|
||||||
|
|
||||||
if ((strncmp(sstime, TCFG.zmh_start, 5) >= 0) && (strncmp(sstime, TCFG.zmh_end, 5) < 0)) {
|
if ((strncmp(sstime, TCFG.zmh_start, 5) >= 0) && (strncmp(sstime, TCFG.zmh_end, 5) < 0)) {
|
||||||
if (!ZMH) {
|
if (!ZMH) {
|
||||||
@ -292,7 +304,7 @@ char *stat_status()
|
|||||||
|
|
||||||
buf[0] = '\0';
|
buf[0] = '\0';
|
||||||
sprintf(buf, "100:20,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%d,%d,%d,%d,%d,%2.2f,%lu;",
|
sprintf(buf, "100:20,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%d,%d,%d,%d,%d,%2.2f,%lu;",
|
||||||
status.start, status.laststart, status.daily,
|
(long)status.start, (long)status.laststart, (long)status.daily,
|
||||||
status.startups, status.clients,
|
status.startups, status.clients,
|
||||||
status.total.tot_clt, status.total.peak_clt,
|
status.total.tot_clt, status.total.peak_clt,
|
||||||
status.total.s_error, status.total.c_error,
|
status.total.s_error, status.total.c_error,
|
||||||
|
@ -70,7 +70,11 @@ char *date(void)
|
|||||||
static char buf[20];
|
static char buf[20];
|
||||||
|
|
||||||
now = time(NULL);
|
now = time(NULL);
|
||||||
|
#if defined(__OpenBSD__)
|
||||||
|
localtime_r(&now, &ptm);
|
||||||
|
#else
|
||||||
ptm = *localtime(&now);
|
ptm = *localtime(&now);
|
||||||
|
#endif
|
||||||
sprintf(buf,"%02d-%s-%04d %02d:%02d:%02d", ptm.tm_mday, mon[ptm.tm_mon], ptm.tm_year+1900,
|
sprintf(buf,"%02d-%s-%04d %02d:%02d:%02d", ptm.tm_mday, mon[ptm.tm_mon], ptm.tm_year+1900,
|
||||||
ptm.tm_hour, ptm.tm_min, ptm.tm_sec);
|
ptm.tm_hour, ptm.tm_min, ptm.tm_sec);
|
||||||
return(buf);
|
return(buf);
|
||||||
@ -477,12 +481,16 @@ static char *dow[] = {(char *)"su", (char *)"mo", (char *)"tu", (char *)"we",
|
|||||||
char *dayname(void)
|
char *dayname(void)
|
||||||
{
|
{
|
||||||
time_t tt;
|
time_t tt;
|
||||||
struct tm *ptm;
|
struct tm ptm;
|
||||||
static char buf[3];
|
static char buf[3];
|
||||||
|
|
||||||
tt = time(NULL);
|
tt = time(NULL);
|
||||||
ptm = localtime(&tt);
|
#if defined(__OpenBSD__)
|
||||||
sprintf(buf, "%s", dow[ptm->tm_wday]);
|
localtime_r(&tt, &ptm);
|
||||||
|
#else
|
||||||
|
ptm = *localtime(&tt);
|
||||||
|
#endif
|
||||||
|
sprintf(buf, "%s", dow[ptm.tm_wday]);
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user