mbtask fixes for z2 mailhour
This commit is contained in:
parent
423e1b3022
commit
e510871928
@ -1210,9 +1210,14 @@ void scheduler(void)
|
|||||||
initnl();
|
initnl();
|
||||||
sem_set((char *)"scanout", TRUE);
|
sem_set((char *)"scanout", TRUE);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Enter the mainloop (forever)
|
||||||
|
*/
|
||||||
do {
|
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.fd = sock;
|
||||||
pfd.events = POLLIN | POLLPRI;
|
pfd.events = POLLIN | POLLPRI;
|
||||||
@ -1227,6 +1232,9 @@ void scheduler(void)
|
|||||||
}
|
}
|
||||||
} else if (rc) {
|
} else if (rc) {
|
||||||
if (pfd.revents & POLLIN) {
|
if (pfd.revents & POLLIN) {
|
||||||
|
/*
|
||||||
|
* Process the clients request
|
||||||
|
*/
|
||||||
memset(&buf, 0, sizeof(buf));
|
memset(&buf, 0, sizeof(buf));
|
||||||
fromlen = sizeof(from);
|
fromlen = sizeof(from);
|
||||||
rlen = recvfrom(sock, buf, sizeof(buf) -1, 0, &from, &fromlen);
|
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
|
* Touch the mbtask.last semafore to prove this daemon
|
||||||
* is actually running.
|
* is actually running.
|
||||||
* Reload configuration data if the file is changed.
|
* Reload configuration data if some file is changed.
|
||||||
*/
|
*/
|
||||||
now = time(NULL);
|
now = time(NULL);
|
||||||
tm = localtime(&now);
|
tm = localtime(&now);
|
||||||
utm = gmtime(&now);
|
utm = gmtime(&now);
|
||||||
if (tm->tm_min != olddo) {
|
if (tm->tm_min != olddo) {
|
||||||
|
/*
|
||||||
|
* Each minute we execute this part
|
||||||
|
*/
|
||||||
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) {
|
||||||
@ -1312,7 +1323,7 @@ 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)) {
|
||||||
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);
|
sem_set((char *)"scanout", TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1337,6 +1348,8 @@ void scheduler(void)
|
|||||||
/*
|
/*
|
||||||
* Here we run all normal operations.
|
* Here we run all normal operations.
|
||||||
*/
|
*/
|
||||||
|
running = checktasks(0);
|
||||||
|
|
||||||
if (s_mailout && (!ptimer) && (!runtasktype(MBFIDO))) {
|
if (s_mailout && (!ptimer) && (!runtasktype(MBFIDO))) {
|
||||||
launch(TCFG.cmd_mailout, NULL, (char *)"mailout", MBFIDO);
|
launch(TCFG.cmd_mailout, NULL, (char *)"mailout", MBFIDO);
|
||||||
running = checktasks(0);
|
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)) {
|
if (s_reqindex && (!ptimer) && (!running)) {
|
||||||
launch(TCFG.cmd_reqindex, NULL, (char *)"reqindex", MBFILE);
|
launch(TCFG.cmd_reqindex, NULL, (char *)"reqindex", MBFILE);
|
||||||
@ -1523,22 +1536,11 @@ void scheduler(void)
|
|||||||
cmd = NULL;
|
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) {
|
switch (pingstate) {
|
||||||
case P_NONE: pingresult[pingnr] = TRUE;
|
case P_NONE: pingresult[pingnr] = TRUE;
|
||||||
break;
|
break;
|
||||||
|
@ -80,11 +80,9 @@ void set_next(int hour, int min)
|
|||||||
if (hour < nxt_hour) {
|
if (hour < nxt_hour) {
|
||||||
nxt_hour = hour;
|
nxt_hour = hour;
|
||||||
nxt_min = min;
|
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)) {
|
} else if ((hour == nxt_hour) && (min < nxt_min)) {
|
||||||
nxt_hour = hour;
|
nxt_hour = hour;
|
||||||
nxt_min = min;
|
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 outstat()
|
||||||
{
|
{
|
||||||
int rc, first = TRUE, T_window, iszmh = FALSE, pass_midnight;
|
int rc, first = TRUE, T_window, iszmh = FALSE;
|
||||||
struct _alist *tmp, *old;
|
struct _alist *tmp, *old;
|
||||||
char flstr[13];
|
char flstr[13];
|
||||||
char temp[81];
|
char temp[81];
|
||||||
@ -187,7 +185,7 @@ int outstat()
|
|||||||
set_next(9, 0);
|
set_next(9, 0);
|
||||||
set_next(10, 0);
|
set_next(10, 0);
|
||||||
break;
|
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;
|
iszmh = TRUE;
|
||||||
set_next(2, 30);
|
set_next(2, 30);
|
||||||
set_next(3, 30);
|
set_next(3, 30);
|
||||||
@ -235,38 +233,44 @@ int outstat()
|
|||||||
tmin = 30;
|
tmin = 30;
|
||||||
sprintf(be, "%02d:%02d", thour, tmin);
|
sprintf(be, "%02d:%02d", thour, tmin);
|
||||||
set_next(thour, tmin);
|
set_next(thour, tmin);
|
||||||
if (strcmp(as, be) > 0)
|
if (strcmp(as, be) > 0) {
|
||||||
pass_midnight = TRUE;
|
/*
|
||||||
else
|
* Time window is passing midnight
|
||||||
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(utc, as) >= 0) || (strcmp(utc, be) < 0))
|
if ((strcmp(utc, as) >= 0) || (strcmp(utc, be) < 0))
|
||||||
T_window = TRUE;
|
T_window = TRUE;
|
||||||
} else {
|
} 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))
|
if ((strcmp(utc, as) >= 0) && (strcmp(utc, be) < 0))
|
||||||
T_window = TRUE;
|
T_window = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tasklog('o', "T_window=%s, iszmh=%s", T_window?"true":"false", iszmh?"true":"false");
|
tasklog('o', "T_window=%s, iszmh=%s", T_window?"true":"false", iszmh?"true":"false");
|
||||||
strcpy(flstr,"...... ... ..");
|
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 ) {
|
if ((tmp->flavors) & F_IMM ) {
|
||||||
flstr[0]='I';
|
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;
|
tmp->flavors |= F_CALL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((tmp->flavors) & F_CRASH ) {
|
if ((tmp->flavors) & F_CRASH ) {
|
||||||
flstr[1]='C';
|
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;
|
tmp->flavors |= F_CALL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -274,10 +278,8 @@ int outstat()
|
|||||||
flstr[2]='N';
|
flstr[2]='N';
|
||||||
/*
|
/*
|
||||||
* Normal mail, send during ZMH or if node has a Txx window.
|
* 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 &&
|
if (iszmh || T_window) {
|
||||||
((tmp->ipflags & IP_IBN) || (tmp->ipflags & IP_IFC) || (tmp->ipflags & IP_ITN)))) {
|
|
||||||
tmp->flavors |= F_CALL;
|
tmp->flavors |= F_CALL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -299,6 +301,7 @@ int outstat()
|
|||||||
*/
|
*/
|
||||||
tmp->flavors &= ~F_CALL;
|
tmp->flavors &= ~F_CALL;
|
||||||
}
|
}
|
||||||
|
/* Check retry timer also here */
|
||||||
if ((tmp->flavors) & F_CALL )
|
if ((tmp->flavors) & F_CALL )
|
||||||
flstr[9]='C';
|
flstr[9]='C';
|
||||||
if (tmp->t1)
|
if (tmp->t1)
|
||||||
@ -320,7 +323,6 @@ int outstat()
|
|||||||
((tmp->ipflags & IP_IBN) || (tmp->ipflags & IP_IFC) || (tmp->ipflags & IP_ITN))) {
|
((tmp->ipflags & IP_IBN) || (tmp->ipflags & IP_IFC) || (tmp->ipflags & IP_ITN))) {
|
||||||
inet_calls++;
|
inet_calls++;
|
||||||
tmp->callmode = CM_INET;
|
tmp->callmode = CM_INET;
|
||||||
tasklog('o', "Call over internet");
|
|
||||||
}
|
}
|
||||||
if (!TCFG.ipblocks || (TCFG.ipblocks && !internet)) {
|
if (!TCFG.ipblocks || (TCFG.ipblocks && !internet)) {
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user