mbtask fixes for z2 mailhour

This commit is contained in:
Michiel Broek 2001-12-30 15:04:11 +00:00
parent 423e1b3022
commit e510871928
2 changed files with 42 additions and 38 deletions

View File

@ -1210,9 +1210,14 @@ void scheduler(void)
initnl();
sem_set((char *)"scanout", TRUE);
/*
* Enter the mainloop (forever)
*/
do {
/*
* Poll UNIX Datagram socket until the defined timeout.
* Poll UNIX Datagram socket until the defined timeout of one second.
* This means we listen of a MBSE BBS client program has something
* to tell.
*/
pfd.fd = sock;
pfd.events = POLLIN | POLLPRI;
@ -1227,6 +1232,9 @@ void scheduler(void)
}
} else if (rc) {
if (pfd.revents & POLLIN) {
/*
* Process the clients request
*/
memset(&buf, 0, sizeof(buf));
fromlen = sizeof(from);
rlen = recvfrom(sock, buf, sizeof(buf) -1, 0, &from, &fromlen);
@ -1284,12 +1292,15 @@ void scheduler(void)
/*
* Touch the mbtask.last semafore to prove this daemon
* is actually running.
* Reload configuration data if the file is changed.
* Reload configuration data if some file is changed.
*/
now = time(NULL);
tm = localtime(&now);
utm = gmtime(&now);
if (tm->tm_min != olddo) {
/*
* Each minute we execute this part
*/
olddo = tm->tm_min;
TouchSema((char *)"mbtask.last");
if (file_time(tcfgfn) != tcfg_time) {
@ -1312,7 +1323,7 @@ void scheduler(void)
* If the next event time is reached, rescan the outbound
*/
if ((utm->tm_hour == nxt_hour) && (utm->tm_min == nxt_min)) {
tasklog('o', "Next event time reached %02d:%02d %02d:%02d", tm->tm_hour, tm->tm_min, utm->tm_hour, utm->tm_min);
tasklog('+', "It is now %02d:%02d UTC, starting new event", utm->tm_hour, utm->tm_min);
sem_set((char *)"scanout", TRUE);
}
}
@ -1337,6 +1348,8 @@ void scheduler(void)
/*
* Here we run all normal operations.
*/
running = checktasks(0);
if (s_mailout && (!ptimer) && (!runtasktype(MBFIDO))) {
launch(TCFG.cmd_mailout, NULL, (char *)"mailout", MBFIDO);
running = checktasks(0);
@ -1383,7 +1396,7 @@ void scheduler(void)
}
/*
* Creating filerequest indexes.
* Creating filerequest indexes, also only if nothing to do.
*/
if (s_reqindex && (!ptimer) && (!running)) {
launch(TCFG.cmd_reqindex, NULL, (char *)"reqindex", MBFILE);
@ -1523,22 +1536,11 @@ void scheduler(void)
cmd = NULL;
}
}
/*
* Run the mailer if something to do. For now we run just
* one task and lock it with CALL_POTS.
* Later tasks for different calltypes should run parallel.
*/
// if (s_scanout && !runtasktype(CALL_POTS)) {
// cmd = xstrcpy(pw->pw_dir);
// cmd = xstrcat(cmd, (char *)"/bin/mbcico");
// launch(cmd, (char *)"-r1", (char *)"mbcico", CALL_POTS);
// running = checktasks(0);
// free(cmd);
// cmd = NULL;
// }
}
/*
* PING state changes
*/
switch (pingstate) {
case P_NONE: pingresult[pingnr] = TRUE;
break;

View File

@ -80,11 +80,9 @@ void set_next(int hour, int min)
if (hour < nxt_hour) {
nxt_hour = hour;
nxt_min = min;
tasklog('o', "set_next(%02d:%02d), next event setting %02d:%02d", hour, min, nxt_hour, nxt_min);
} else if ((hour == nxt_hour) && (min < nxt_min)) {
nxt_hour = hour;
nxt_min = min;
tasklog('o', "set_next(%02d:%02d), next event setting %02d:%02d", hour, min, nxt_hour, nxt_min);
}
}
}
@ -131,7 +129,7 @@ char *callmode(int mode)
int outstat()
{
int rc, first = TRUE, T_window, iszmh = FALSE, pass_midnight;
int rc, first = TRUE, T_window, iszmh = FALSE;
struct _alist *tmp, *old;
char flstr[13];
char temp[81];
@ -187,7 +185,7 @@ int outstat()
set_next(9, 0);
set_next(10, 0);
break;
case 2: if (((uhour >= 2) && (umin >= 30)) && ((uhour <= 3) && (umin < 30)))
case 2: if (((uhour == 2) && (umin >= 30)) || ((uhour == 3) && (umin < 30)))
iszmh = TRUE;
set_next(2, 30);
set_next(3, 30);
@ -235,38 +233,44 @@ int outstat()
tmin = 30;
sprintf(be, "%02d:%02d", thour, tmin);
set_next(thour, tmin);
if (strcmp(as, be) > 0)
pass_midnight = TRUE;
else
pass_midnight = FALSE;
tasklog('o', "window %s - %s, pass midnight=%s, %d", as, be, pass_midnight?"true":"false", strcmp(as, be));
if (pass_midnight) {
tasklog('o', "strcmp(utc, as)=%d strcmp(utc, be)=%d", strcmp(utc, as), strcmp(utc, be));
if (strcmp(as, be) > 0) {
/*
* Time window is passing midnight
*/
if ((strcmp(utc, as) >= 0) || (strcmp(utc, be) < 0))
T_window = TRUE;
} else {
tasklog('o', "strcmp(utc, as)=%d strcmp(utc, be)=%d", strcmp(utc, as), strcmp(utc, be));
/*
* Time window is not passing midnight
*/
if ((strcmp(utc, as) >= 0) && (strcmp(utc, be) < 0))
T_window = TRUE;
}
}
tasklog('o', "T_window=%s, iszmh=%s", T_window?"true":"false", iszmh?"true":"false");
strcpy(flstr,"...... ... ..");
/*
* If the node has internet and we have internet available, check if we can send
* immediatly.
*/
if (internet && TCFG.max_tcp && ((tmp->ipflags & IP_IBN) || (tmp->ipflags & IP_IFC) || (tmp->ipflags & IP_ITN))) {
tmp->flavors |= F_CALL;
}
if ((tmp->flavors) & F_IMM ) {
flstr[0]='I';
/*
* Immediate mail, send if node is CM.
* Immediate mail, send if node is CM or is in a Txx window or is in ZMH.
*/
if ((tmp->olflags & OL_CM) || T_window) {
if ((tmp->olflags & OL_CM) || T_window || iszmh) {
tmp->flavors |= F_CALL;
}
}
if ((tmp->flavors) & F_CRASH ) {
flstr[1]='C';
/*
* Crash mail, send if node is CM.
* Crash mail, send if node is CM or is in a Txx window or is in ZMH.
*/
if ((tmp->olflags & OL_CM) || T_window) {
if ((tmp->olflags & OL_CM) || T_window || iszmh) {
tmp->flavors |= F_CALL;
}
}
@ -274,10 +278,8 @@ int outstat()
flstr[2]='N';
/*
* Normal mail, send during ZMH or if node has a Txx window.
* Also if node has TCP/IP capability and internet is ready.
*/
if (iszmh || T_window || (internet && TCFG.max_tcp &&
((tmp->ipflags & IP_IBN) || (tmp->ipflags & IP_IFC) || (tmp->ipflags & IP_ITN)))) {
if (iszmh || T_window) {
tmp->flavors |= F_CALL;
}
}
@ -299,6 +301,7 @@ int outstat()
*/
tmp->flavors &= ~F_CALL;
}
/* Check retry timer also here */
if ((tmp->flavors) & F_CALL )
flstr[9]='C';
if (tmp->t1)
@ -320,7 +323,6 @@ int outstat()
((tmp->ipflags & IP_IBN) || (tmp->ipflags & IP_IFC) || (tmp->ipflags & IP_ITN))) {
inet_calls++;
tmp->callmode = CM_INET;
tasklog('o', "Call over internet");
}
if (!TCFG.ipblocks || (TCFG.ipblocks && !internet)) {
/*