Check for stopped tasks reverted to the old method without signal handlers
This commit is contained in:
parent
f50554acfc
commit
725b68c22f
@ -11,6 +11,8 @@ v0.83.20 27-May-2006
|
|||||||
Registration info for the clients was send double coded.
|
Registration info for the clients was send double coded.
|
||||||
Delete users from channel when a server disconnects.
|
Delete users from channel when a server disconnects.
|
||||||
Delete users from a server when server disconnects.
|
Delete users from a server when server disconnects.
|
||||||
|
Check for stopped tasks reverted to the old method without
|
||||||
|
signal handlers.
|
||||||
|
|
||||||
|
|
||||||
v0.83.19 23-May-2006 - 27-May-2006
|
v0.83.19 23-May-2006 - 27-May-2006
|
||||||
|
148
mbtask/mbtask.c
148
mbtask/mbtask.c
@ -117,6 +117,8 @@ extern time_t resettime; /* IBC reset time */
|
|||||||
int Run_IBC = TRUE; /* Run IBC server */
|
int Run_IBC = TRUE; /* Run IBC server */
|
||||||
|
|
||||||
|
|
||||||
|
void logtasks(void);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Load main configuration, if it doesn't exist, create it.
|
* Load main configuration, if it doesn't exist, create it.
|
||||||
@ -473,7 +475,7 @@ pid_t launch(char *cmd, char *opts, char *name, int tasktype)
|
|||||||
Syslog('?', "Launch: can't execute %s, maximum tasks reached", cmd);
|
Syslog('?', "Launch: can't execute %s, maximum tasks reached", cmd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
// memset(vector, 0, sizeof(vector));
|
|
||||||
for (i = 0; i < 16; i++)
|
for (i = 0; i < 16; i++)
|
||||||
vector[i] = NULL;
|
vector[i] = NULL;
|
||||||
|
|
||||||
@ -554,6 +556,7 @@ pid_t launch(char *cmd, char *opts, char *name, int tasktype)
|
|||||||
task[i].running = TRUE;
|
task[i].running = TRUE;
|
||||||
task[i].rc = 0;
|
task[i].rc = 0;
|
||||||
task[i].tasktype = tasktype;
|
task[i].tasktype = tasktype;
|
||||||
|
logtasks();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -585,23 +588,18 @@ int runtasktype(int tasktype)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
void logtasks(void)
|
||||||
* Signal handler for finished tasks
|
|
||||||
*/
|
|
||||||
void taskdie(int);
|
|
||||||
void taskdie(int onsig)
|
|
||||||
{
|
{
|
||||||
int i, status;
|
int i, first = TRUE;
|
||||||
|
|
||||||
for (i = 0; i < MAXTASKS; i++) {
|
if (first) {
|
||||||
if (strlen(task[i].name)) {
|
first = FALSE;
|
||||||
task[i].rc = wait4(task[i].pid, &status, WNOHANG | WUNTRACED, NULL);
|
Syslog('t', "Task Type pid stat rc");
|
||||||
if (task[i].rc) {
|
Syslog('t', "---------------- ------- ----- ---- -----");
|
||||||
task[i].running = FALSE;
|
for (i = 0; i < MAXTASKS; i++)
|
||||||
task[i].status = status;
|
if (strlen(task[i].name))
|
||||||
Syslog('t', "taskdie() set task %d got signal, rc=%d, status=%d", i, task[i].rc, status);
|
Syslog('t', "%-16s %s %5d %s %5d", task[i].name, callmode(task[i].tasktype),
|
||||||
}
|
task[i].pid, task[i].running?"runs":"stop", task[i].rc);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -614,7 +612,7 @@ void taskdie(int onsig)
|
|||||||
*/
|
*/
|
||||||
int checktasks(int onsig)
|
int checktasks(int onsig)
|
||||||
{
|
{
|
||||||
int i, j, rc, count = 0, first = TRUE;
|
int i, j, rc, count = 0, status;
|
||||||
|
|
||||||
for (i = 0; i < MAXTASKS; i++) {
|
for (i = 0; i < MAXTASKS; i++) {
|
||||||
if (strlen(task[i].name)) {
|
if (strlen(task[i].name)) {
|
||||||
@ -626,18 +624,22 @@ int checktasks(int onsig)
|
|||||||
Syslog('+', "%s to %s (pid %d) failed", SigName[onsig], task[i].name, task[i].pid);
|
Syslog('+', "%s to %s (pid %d) failed", SigName[onsig], task[i].name, task[i].pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task[i].rc = wait4(task[i].pid, &status, WNOHANG | WUNTRACED, NULL);
|
||||||
|
task[i].status = status;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If task was set not running by taskdie(), handle status
|
* If task was set not running, handle status
|
||||||
*/
|
*/
|
||||||
if (task[i].running) {
|
if (task[i].rc) {
|
||||||
count++;
|
task[i].running = FALSE;
|
||||||
} else {
|
|
||||||
/*
|
/*
|
||||||
* If a mailer call is finished, set the global rescan flag.
|
* If a mailer call is finished, set the global rescan flag.
|
||||||
*/
|
*/
|
||||||
if (task[i].tasktype == CM_POTS || task[i].tasktype == CM_ISDN || task[i].tasktype == CM_INET)
|
if (task[i].tasktype == CM_POTS || task[i].tasktype == CM_ISDN || task[i].tasktype == CM_INET)
|
||||||
rescan = TRUE;
|
rescan = TRUE;
|
||||||
ptimer = PAUSETIME;
|
ptimer = PAUSETIME;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If a nodelist compiler is ready, reload the nodelists configuration
|
* If a nodelist compiler is ready, reload the nodelists configuration
|
||||||
*/
|
*/
|
||||||
@ -646,53 +648,53 @@ int checktasks(int onsig)
|
|||||||
initnl();
|
initnl();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (first) {
|
logtasks();
|
||||||
first = FALSE;
|
}
|
||||||
Syslog('t', "Task Type pid stat");
|
|
||||||
Syslog('t', "---------------- ------- ----- ----");
|
switch (task[i].rc) {
|
||||||
for (j = 0; j < MAXTASKS; j++)
|
case -1:
|
||||||
if (strlen(task[j].name))
|
if (errno == ECHILD)
|
||||||
Syslog('t', "%-16s %s %5d %s", task[j].name, callmode(task[j].tasktype),
|
Syslog('+', "Task %d \"%s\" is ready", i, task[i].name);
|
||||||
task[j].pid, task[j].running?"runs":"stop");
|
else
|
||||||
}
|
Syslog('+', "Task %d \"%s\" is ready, error: %s", i, task[i].name, strerror(errno));
|
||||||
|
break;
|
||||||
switch (task[i].rc) {
|
case 0:
|
||||||
case -1:
|
/*
|
||||||
if (errno == ECHILD)
|
* Update last known status when running.
|
||||||
Syslog('+', "Task %d \"%s\" is ready", i, task[i].name);
|
*/
|
||||||
|
task[i].status = status;
|
||||||
|
count++;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (WIFEXITED(task[i].status)) {
|
||||||
|
rc = WEXITSTATUS(task[i].status);
|
||||||
|
if (rc)
|
||||||
|
Syslog('+', "Task %s is ready, error=%d", task[i].name, rc);
|
||||||
else
|
else
|
||||||
Syslog('+', "Task %d \"%s\" is ready, error: %s", i, task[i].name, strerror(errno));
|
Syslog('+', "Task %s is ready", task[i].name);
|
||||||
break;
|
} else if (WIFSIGNALED(task[i].status)) {
|
||||||
case 0:
|
rc = WTERMSIG(task[i].status);
|
||||||
break;
|
/*
|
||||||
default:
|
* Here we don't report an error number, on FreeBSD WIFSIGNALED
|
||||||
if (WIFEXITED(task[i].status)) {
|
* seems true while there's nothing wrong.
|
||||||
rc = WEXITSTATUS(task[i].status);
|
*/
|
||||||
if (rc)
|
Syslog('+', "Task %s terminated", task[i].name);
|
||||||
Syslog('+', "Task %s is ready, error=%d", task[i].name, rc);
|
} else if (WIFSTOPPED(task[i].status)) {
|
||||||
else
|
rc = WSTOPSIG(task[i].status);
|
||||||
Syslog('+', "Task %s is ready", task[i].name);
|
Syslog('+', "Task %s stopped on signal %s (%d)", task[i].name, SigName[rc], rc);
|
||||||
} else if (WIFSIGNALED(task[i].status)) {
|
}
|
||||||
rc = WTERMSIG(task[i].status);
|
break;
|
||||||
/*
|
}
|
||||||
* Here we don't report an error number, on FreeBSD WIFSIGNALED
|
|
||||||
* seems true while there's nothing wrong.
|
|
||||||
*/
|
|
||||||
Syslog('+', "Task %s terminated", task[i].name);
|
|
||||||
} else if (WIFSTOPPED(task[i].status)) {
|
|
||||||
rc = WSTOPSIG(task[i].status);
|
|
||||||
Syslog('+', "Task %s stopped on signal %s (%d)", task[i].name, SigName[rc], rc);
|
|
||||||
} else {
|
|
||||||
Syslog('+', "FIXME: 1");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (j = 0; j < MAXTASKS; j++) {
|
/*
|
||||||
if (calllist[j].taskpid == task[i].pid) {
|
* Remove finished task from the list
|
||||||
calllist[j].calling = FALSE;
|
*/
|
||||||
calllist[j].taskpid = 0;
|
if (!task[i].running) {
|
||||||
rescan = TRUE;
|
for (j = 0; j < MAXTASKS; j++) {
|
||||||
|
if (calllist[j].taskpid == task[i].pid) {
|
||||||
|
calllist[j].calling = FALSE;
|
||||||
|
calllist[j].taskpid = 0;
|
||||||
|
rescan = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
memset(&task[i], 0, sizeof(onetask));
|
memset(&task[i], 0, sizeof(onetask));
|
||||||
@ -1128,11 +1130,9 @@ void scheduler(void)
|
|||||||
*/
|
*/
|
||||||
do {
|
do {
|
||||||
/*
|
/*
|
||||||
* Poll UNIX Datagram socket and IBC UDP socket until the defined
|
* Poll UNIX Datagram socket and IBC UDP socket until the defined timeout of one second.
|
||||||
* timeout of one second.
|
* This means we listen if a MBSE BBS client program has something to tell us.
|
||||||
* This means we listen if a MBSE BBS client program has something
|
* Timeout is one second, after the timeout the rest of the mainloop is executed.
|
||||||
* to tell. Timeout is one second, after the timeout the rest of the
|
|
||||||
* mainloop is executed.
|
|
||||||
*/
|
*/
|
||||||
pfd[0].fd = sock;
|
pfd[0].fd = sock;
|
||||||
pfd[0].events = POLLIN;
|
pfd[0].events = POLLIN;
|
||||||
@ -1560,8 +1560,8 @@ int main(int argc, char **argv)
|
|||||||
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
|
||||||
signal(i, (void (*))taskdie);
|
signal(i, SIG_IGN);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user