diff --git a/ChangeLog b/ChangeLog index e6c67d66..87cda1f2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -111,6 +111,10 @@ v0.61.4 11-Aug-2004 The magic filenames directory is moved from ~/magic to ~/var/magic. The semafore directory is moved from ~/sema to ~/var/sema. + When shutting down on UPS semafore "upsdown", the log was + garbled. + When shutting down on an external event and there were users + online, mbtask did not wait. mbsetup: Changed nodes screens to have a separate uplink managers setup diff --git a/mbtask/mbtask.c b/mbtask/mbtask.c index 2dd4de46..5e15278e 100644 --- a/mbtask/mbtask.c +++ b/mbtask/mbtask.c @@ -82,6 +82,7 @@ double Load; /* System Load */ int Processing; /* Is system running */ int ZMH = FALSE; /* Zone Mail Hour */ int UPSalarm = FALSE; /* UPS alarm status */ +int UPSdown = FALSE; /* UPS down status */ extern int s_bbsopen; /* BBS open semafore */ extern int s_scanout; /* Scan outbound sema */ extern int s_mailout; /* Mail out semafore */ @@ -658,14 +659,19 @@ void start_shutdown(int onsig) void die(int onsig) { int i, count; + char temp[80]; time_t now; signal(onsig, SIG_IGN); - if ((onsig == SIGTERM) || (nodaemon && (onsig == SIGINT))) { - Syslog('+', "Starting normal shutdown (%s)", SigName[onsig]); + if (onsig < NSIG) { + if ((onsig == SIGTERM) || (nodaemon && (onsig == SIGINT))) { + Syslog('+', "Starting normal shutdown (%s)", SigName[onsig]); + } else { + Syslog('+', "Abnormal shutdown on signal %s", SigName[onsig]); + } } else { - Syslog('+', "Abnormal shutdown on signal %s", SigName[onsig]); + Syslog('+', "Shutdown on error %d", onsig); } /* @@ -700,6 +706,25 @@ void die(int onsig) else Syslog('+', "Good, no more tasks running"); + /* + * Now check for users online and other programs not started + * under control of mbtask. + */ + count = 30; + while (count) { + sprintf(temp, "%s", reg_fre()); + if (strcmp(temp, "100:0;") == 0) { + Syslog('+', "Good, no more other programs running"); + break; + } + Syslog('+', "%s", temp+6); + sleep(1); + count--; + } + if ((count == 0) && strcmp(temp, "100:0;")) { + Syslog('?', "Continue shutdown with other programs running"); + } + /* * Now stop the threads */ @@ -890,6 +915,7 @@ void check_sema(void) } if (IsSema((char *)"upsdown")) { Syslog('!', "UPS: power failure, starting shutdown"); + UPSdown = TRUE; /* * Since the upsdown semafore is permanent, the system WILL go down * there is no point for this program to stay. Signal all tasks and stop. @@ -1081,6 +1107,8 @@ void *scheduler(void) memset(&doing, 0, sizeof(doing)); if ((running = checktasks(0))) sprintf(doing, "Run %d tasks", running); + else if (UPSdown) + sprintf(doing, "UPS shutdown"); else if (UPSalarm) sprintf(doing, "UPS alarm"); else if (!s_bbsopen) diff --git a/mbtask/taskstat.c b/mbtask/taskstat.c index fc391ae0..89e8af64 100644 --- a/mbtask/taskstat.c +++ b/mbtask/taskstat.c @@ -51,6 +51,7 @@ int s_bbsopen = FALSE; int s_do_inet = FALSE; int tosswait = TOSSWAIT_TIME; extern int UPSalarm; +extern int UPSdown; extern int ptimer; extern int rescan; @@ -394,6 +395,8 @@ char *sem_status(char *data) value = s_reqindex; } else if (!strcmp(sem, "upsalarm")) { value = UPSalarm; + } else if (!strcmp(sem, "upsdown")) { + value = UPSdown; } else if (!strcmp(sem, "do_inet")) { value = s_do_inet; } else {