Fixed mbtask shutdown on UPS shutdown

This commit is contained in:
Michiel Broek 2004-09-19 14:08:01 +00:00
parent 1a754bcccb
commit 4255e9d3b1
3 changed files with 38 additions and 3 deletions

View File

@ -111,6 +111,10 @@ v0.61.4 11-Aug-2004
The magic filenames directory is moved from ~/magic to The magic filenames directory is moved from ~/magic to
~/var/magic. ~/var/magic.
The semafore directory is moved from ~/sema to ~/var/sema. 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: mbsetup:
Changed nodes screens to have a separate uplink managers setup Changed nodes screens to have a separate uplink managers setup

View File

@ -82,6 +82,7 @@ double Load; /* System Load */
int Processing; /* Is system running */ int Processing; /* Is system running */
int ZMH = FALSE; /* Zone Mail Hour */ int ZMH = FALSE; /* Zone Mail Hour */
int UPSalarm = FALSE; /* UPS alarm status */ int UPSalarm = FALSE; /* UPS alarm status */
int UPSdown = FALSE; /* UPS down status */
extern int s_bbsopen; /* BBS open semafore */ extern int s_bbsopen; /* BBS open semafore */
extern int s_scanout; /* Scan outbound sema */ extern int s_scanout; /* Scan outbound sema */
extern int s_mailout; /* Mail out semafore */ extern int s_mailout; /* Mail out semafore */
@ -658,15 +659,20 @@ void start_shutdown(int onsig)
void die(int onsig) void die(int onsig)
{ {
int i, count; int i, count;
char temp[80];
time_t now; time_t now;
signal(onsig, SIG_IGN); signal(onsig, SIG_IGN);
if (onsig < NSIG) {
if ((onsig == SIGTERM) || (nodaemon && (onsig == SIGINT))) { if ((onsig == SIGTERM) || (nodaemon && (onsig == SIGINT))) {
Syslog('+', "Starting normal shutdown (%s)", SigName[onsig]); Syslog('+', "Starting normal shutdown (%s)", SigName[onsig]);
} else { } else {
Syslog('+', "Abnormal shutdown on signal %s", SigName[onsig]); Syslog('+', "Abnormal shutdown on signal %s", SigName[onsig]);
} }
} else {
Syslog('+', "Shutdown on error %d", onsig);
}
/* /*
* First check if there are tasks running, if so try to stop them * First check if there are tasks running, if so try to stop them
@ -700,6 +706,25 @@ void die(int onsig)
else else
Syslog('+', "Good, no more tasks running"); 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 * Now stop the threads
*/ */
@ -890,6 +915,7 @@ void check_sema(void)
} }
if (IsSema((char *)"upsdown")) { if (IsSema((char *)"upsdown")) {
Syslog('!', "UPS: power failure, starting shutdown"); Syslog('!', "UPS: power failure, starting shutdown");
UPSdown = TRUE;
/* /*
* Since the upsdown semafore is permanent, the system WILL go down * 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. * 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)); memset(&doing, 0, sizeof(doing));
if ((running = checktasks(0))) if ((running = checktasks(0)))
sprintf(doing, "Run %d tasks", running); sprintf(doing, "Run %d tasks", running);
else if (UPSdown)
sprintf(doing, "UPS shutdown");
else if (UPSalarm) else if (UPSalarm)
sprintf(doing, "UPS alarm"); sprintf(doing, "UPS alarm");
else if (!s_bbsopen) else if (!s_bbsopen)

View File

@ -51,6 +51,7 @@ int s_bbsopen = FALSE;
int s_do_inet = FALSE; int s_do_inet = FALSE;
int tosswait = TOSSWAIT_TIME; int tosswait = TOSSWAIT_TIME;
extern int UPSalarm; extern int UPSalarm;
extern int UPSdown;
extern int ptimer; extern int ptimer;
extern int rescan; extern int rescan;
@ -394,6 +395,8 @@ char *sem_status(char *data)
value = s_reqindex; value = s_reqindex;
} else if (!strcmp(sem, "upsalarm")) { } else if (!strcmp(sem, "upsalarm")) {
value = UPSalarm; value = UPSalarm;
} else if (!strcmp(sem, "upsdown")) {
value = UPSdown;
} else if (!strcmp(sem, "do_inet")) { } else if (!strcmp(sem, "do_inet")) {
value = s_do_inet; value = s_do_inet;
} else { } else {