Made tossing mail more relaxed
This commit is contained in:
parent
e52324bf3a
commit
c20e041625
@ -46,6 +46,9 @@ v0.37.01 14-Jan-2003.
|
|||||||
After forking the daemon, the stdin, stdout and stderr are
|
After forking the daemon, the stdin, stdout and stderr are
|
||||||
reopend to /dev/null.
|
reopend to /dev/null.
|
||||||
Zero the daily status counters finally works again.
|
Zero the daily status counters finally works again.
|
||||||
|
Added experimental code where tossing mail is not started as
|
||||||
|
long as there are mailers running, but not longer as 30 mins.
|
||||||
|
This should make the whole system less nervous.
|
||||||
|
|
||||||
mbfile:
|
mbfile:
|
||||||
In the import function several bugfixes for reading files.bbs.
|
In the import function several bugfixes for reading files.bbs.
|
||||||
|
4
TODO
4
TODO
@ -149,10 +149,6 @@ mbtask:
|
|||||||
mbnewusr:
|
mbnewusr:
|
||||||
N: On NetBSD, supress error message from mbpasswd.
|
N: On NetBSD, supress error message from mbpasswd.
|
||||||
|
|
||||||
mbtask:
|
|
||||||
U: When a new user registers and presses enter on the name prompt
|
|
||||||
and then hangs up (at least with telnet), mbtask aborts.
|
|
||||||
|
|
||||||
mbsetup:
|
mbsetup:
|
||||||
N: Add a check for double areatag names.
|
N: Add a check for double areatag names.
|
||||||
|
|
||||||
|
200
mbtask/mbtask.c
200
mbtask/mbtask.c
@ -586,12 +586,12 @@ int checktasks(int onsig)
|
|||||||
|
|
||||||
if (first && task[i].rc) {
|
if (first && task[i].rc) {
|
||||||
first = FALSE;
|
first = FALSE;
|
||||||
Syslog('t', "Task Type pid stat rc");
|
Syslog('t', "Task Type pid stat");
|
||||||
Syslog('t', "---------------- ------- ----- ---- -----");
|
Syslog('t', "---------------- ------- ----- ----");
|
||||||
for (j = 0; j < MAXTASKS; j++)
|
for (j = 0; j < MAXTASKS; j++)
|
||||||
if (strlen(task[j].name))
|
if (strlen(task[j].name))
|
||||||
Syslog('t', "%-16s %s %5d %s %5d", task[j].name, callmode(task[j].tasktype),
|
Syslog('t', "%-16s %s %5d %s", task[j].name, callmode(task[j].tasktype),
|
||||||
task[j].pid, task[j].running?"runs":"stop", task[j].rc);
|
task[j].pid, task[j].running?"runs":"stop");
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (task[i].rc) {
|
switch (task[i].rc) {
|
||||||
@ -650,57 +650,57 @@ int checktasks(int onsig)
|
|||||||
|
|
||||||
void die(int onsig)
|
void die(int onsig)
|
||||||
{
|
{
|
||||||
int i, count;
|
int i, count;
|
||||||
|
|
||||||
signal(onsig, SIG_IGN);
|
signal(onsig, SIG_IGN);
|
||||||
if (onsig == SIGTERM)
|
if (onsig == SIGTERM)
|
||||||
Syslog('+', "Starting normal shutdown");
|
Syslog('+', "Starting normal shutdown");
|
||||||
else
|
else
|
||||||
Syslog('+', "Abnormal shutdown on signal %s", SigName[onsig]);
|
Syslog('+', "Abnormal shutdown on signal %s", SigName[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
|
||||||
*/
|
*/
|
||||||
if ((count = checktasks(0))) {
|
if ((count = checktasks(0))) {
|
||||||
Syslog('+', "There are %d tasks running, sending SIGTERM", count);
|
Syslog('+', "There are %d tasks running, sending SIGTERM", count);
|
||||||
checktasks(SIGTERM);
|
checktasks(SIGTERM);
|
||||||
for (i = 0; i < 15; i++) {
|
for (i = 0; i < 15; i++) {
|
||||||
sleep(1);
|
sleep(1);
|
||||||
count = checktasks(0);
|
count = checktasks(0);
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
if (count) {
|
|
||||||
/*
|
|
||||||
* There are some diehards running...
|
|
||||||
*/
|
|
||||||
Syslog('+', "There are %d tasks running, sending SIGKILL", count);
|
|
||||||
count = checktasks(SIGKILL);
|
|
||||||
}
|
|
||||||
if (count) {
|
|
||||||
sleep(1);
|
|
||||||
count = checktasks(0);
|
|
||||||
if (count)
|
|
||||||
Syslog('?', "Still %d tasks running, giving up", count);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (count) {
|
||||||
if ((count = checktasks(0)))
|
/*
|
||||||
Syslog('?', "Shutdown with %d tasks still running", count);
|
* There are some diehards running...
|
||||||
else
|
*/
|
||||||
Syslog('+', "Good, no more tasks running");
|
Syslog('+', "There are %d tasks running, sending SIGKILL", count);
|
||||||
|
count = checktasks(SIGKILL);
|
||||||
deinitnl();
|
|
||||||
ulocktask();
|
|
||||||
if (sock != -1)
|
|
||||||
close(sock);
|
|
||||||
if (ping_isocket != -1)
|
|
||||||
close(ping_isocket);
|
|
||||||
if (!file_exist(spath, R_OK)) {
|
|
||||||
unlink(spath);
|
|
||||||
}
|
}
|
||||||
Syslog(' ', "MBTASK finished");
|
if (count) {
|
||||||
exit(onsig);
|
sleep(1);
|
||||||
|
count = checktasks(0);
|
||||||
|
if (count)
|
||||||
|
Syslog('?', "Still %d tasks running, giving up", count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((count = checktasks(0)))
|
||||||
|
Syslog('?', "Shutdown with %d tasks still running", count);
|
||||||
|
else
|
||||||
|
Syslog('+', "Good, no more tasks running");
|
||||||
|
|
||||||
|
deinitnl();
|
||||||
|
ulocktask();
|
||||||
|
if (sock != -1)
|
||||||
|
close(sock);
|
||||||
|
if (ping_isocket != -1)
|
||||||
|
close(ping_isocket);
|
||||||
|
if (!file_exist(spath, R_OK)) {
|
||||||
|
unlink(spath);
|
||||||
|
}
|
||||||
|
Syslog(' ', "MBTASK finished");
|
||||||
|
exit(onsig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -781,11 +781,11 @@ void ulocktask(void)
|
|||||||
void test_sema(char *);
|
void test_sema(char *);
|
||||||
void test_sema(char *sema)
|
void test_sema(char *sema)
|
||||||
{
|
{
|
||||||
if (IsSema(sema)) {
|
if (IsSema(sema)) {
|
||||||
RemoveSema(sema);
|
RemoveSema(sema);
|
||||||
Syslog('s', "Semafore %s detected", sema);
|
Syslog('s', "Semafore %s detected", sema);
|
||||||
sem_set(sema, TRUE);
|
sem_set(sema, TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -797,40 +797,40 @@ void test_sema(char *sema)
|
|||||||
void check_sema(void);
|
void check_sema(void);
|
||||||
void check_sema(void)
|
void check_sema(void)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* Check UPS status.
|
||||||
|
*/
|
||||||
|
if (IsSema((char *)"upsalarm")) {
|
||||||
|
if (!UPSalarm)
|
||||||
|
Syslog('!', "UPS: power failure");
|
||||||
|
UPSalarm = TRUE;
|
||||||
|
} else {
|
||||||
|
if (UPSalarm)
|
||||||
|
Syslog('!', "UPS: the power is back");
|
||||||
|
UPSalarm = FALSE;
|
||||||
|
}
|
||||||
|
if (IsSema((char *)"upsdown")) {
|
||||||
|
Syslog('!', "UPS: power failure, starting shutdown");
|
||||||
/*
|
/*
|
||||||
* Check UPS status.
|
* 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.
|
||||||
*/
|
*/
|
||||||
if (IsSema((char *)"upsalarm")) {
|
die(MBERR_UPS_ALARM);
|
||||||
if (!UPSalarm)
|
}
|
||||||
Syslog('!', "UPS: power failure");
|
|
||||||
UPSalarm = TRUE;
|
|
||||||
} else {
|
|
||||||
if (UPSalarm)
|
|
||||||
Syslog('!', "UPS: the power is back");
|
|
||||||
UPSalarm = FALSE;
|
|
||||||
}
|
|
||||||
if (IsSema((char *)"upsdown")) {
|
|
||||||
Syslog('!', "UPS: power failure, starting shutdown");
|
|
||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
die(MBERR_UPS_ALARM);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check Zone Mail Hour
|
* Check Zone Mail Hour
|
||||||
*/
|
*/
|
||||||
get_zmh();
|
get_zmh();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Semafore's that still can be detected, usefull for
|
* Semafore's that still can be detected, usefull for
|
||||||
* external programs that create them.
|
* external programs that create them.
|
||||||
*/
|
*/
|
||||||
test_sema((char *)"newnews");
|
test_sema((char *)"newnews");
|
||||||
test_sema((char *)"mailout");
|
test_sema((char *)"mailout");
|
||||||
test_sema((char *)"mailin");
|
test_sema((char *)"mailin");
|
||||||
test_sema((char *)"scanout");
|
test_sema((char *)"scanout");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -839,7 +839,7 @@ void scheduler(void)
|
|||||||
{
|
{
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
int running = 0, rc, i, rlen, found;
|
int running = 0, rc, i, rlen, found;
|
||||||
static int LOADhi = FALSE, oldmin = 70, olddo = 70, oldsec = 70;
|
static int LOADhi = FALSE, oldmin = 70, olddo = 70, oldsec = 70, tosswait = TOSSWAIT_TIME;
|
||||||
char *cmd = NULL, opts[41], port[21];
|
char *cmd = NULL, opts[41], port[21];
|
||||||
static char doing[32], buf[2048];
|
static char doing[32], buf[2048];
|
||||||
time_t now;
|
time_t now;
|
||||||
@ -1010,6 +1010,8 @@ void scheduler(void)
|
|||||||
/*
|
/*
|
||||||
* Each minute we execute this part
|
* Each minute we execute this part
|
||||||
*/
|
*/
|
||||||
|
if (tosswait)
|
||||||
|
tosswait--;
|
||||||
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) {
|
||||||
@ -1083,9 +1085,27 @@ void scheduler(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (s_mailin && (!ptimer) && (!runtasktype(MBFIDO))) {
|
if (s_mailin && (!ptimer) && (!runtasktype(MBFIDO))) {
|
||||||
launch(TCFG.cmd_mailin, NULL, (char *)"mailin", MBFIDO);
|
/*
|
||||||
running = checktasks(0);
|
* Here we should check if no mailers are running. Only start
|
||||||
s_mailin = FALSE;
|
* processing the inbound if no mailers are running, but on busy
|
||||||
|
* systems this may hardly be the case. So we wait for 30 minutes
|
||||||
|
* and if there are still mailers running, mbfido is started
|
||||||
|
* anyway.
|
||||||
|
*/
|
||||||
|
if ((ipmailers + runtasktype(CM_ISDN) + runtasktype(CM_POTS)) == 0) {
|
||||||
|
Syslog('i', "Mailin, no mailers running, start direct");
|
||||||
|
tosswait = TOSSWAIT_TIME;
|
||||||
|
launch(TCFG.cmd_mailin, NULL, (char *)"mailin", MBFIDO);
|
||||||
|
running = checktasks(0);
|
||||||
|
s_mailin = FALSE;
|
||||||
|
} else {
|
||||||
|
Syslog('i', "Mailin, tosswait=%d", tosswait);
|
||||||
|
if (tosswait == 0) {
|
||||||
|
launch(TCFG.cmd_mailin, NULL, (char *)"mailin", MBFIDO);
|
||||||
|
running = checktasks(0);
|
||||||
|
s_mailin = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s_newnews && (!ptimer) && (!runtasktype(MBFIDO))) {
|
if (s_newnews && (!ptimer) && (!runtasktype(MBFIDO))) {
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
#define SLOWRUN 20
|
#define SLOWRUN 20
|
||||||
#define TMPNAME "TMP."
|
#define TMPNAME "TMP."
|
||||||
#define LCKNAME "LOCKTASK"
|
#define LCKNAME "LOCKTASK"
|
||||||
|
#define TOSSWAIT_TIME 30
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* Purpose ...............: mbtask - ping functions
|
* Purpose ...............: mbtask - ping functions
|
||||||
*
|
*
|
||||||
*****************************************************************************
|
*****************************************************************************
|
||||||
* Copyright (C) 1997-2002
|
* Copyright (C) 1997-2003
|
||||||
*
|
*
|
||||||
* Michiel Broek FIDO: 2:280/2802
|
* Michiel Broek FIDO: 2:280/2802
|
||||||
* Beekmansbos 10
|
* Beekmansbos 10
|
||||||
@ -101,7 +101,6 @@ int ping_receive(struct in_addr);
|
|||||||
#define ICMP4_ECHO_LEN ICMP_BASEHDR_LEN
|
#define ICMP4_ECHO_LEN ICMP_BASEHDR_LEN
|
||||||
|
|
||||||
|
|
||||||
// short p_sequence = 0;
|
|
||||||
short p_sequence = 10;
|
short p_sequence = 10;
|
||||||
unsigned short id;
|
unsigned short id;
|
||||||
struct icmphdr icmpd;
|
struct icmphdr icmpd;
|
||||||
@ -176,7 +175,6 @@ int ping_send(struct in_addr addr)
|
|||||||
SOL_IP = pe->p_proto;
|
SOL_IP = pe->p_proto;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// p_sequence++;
|
|
||||||
id = (unsigned short)get_rand16(); /* randomize a ping id */
|
id = (unsigned short)get_rand16(); /* randomize a ping id */
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
@ -317,13 +315,11 @@ void check_ping(void)
|
|||||||
pingresult[1] = pingresult[2] = internet = FALSE;
|
pingresult[1] = pingresult[2] = internet = FALSE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case P_PAUSE: // Syslog('p', "PAUSE:");
|
case P_PAUSE: if (time(NULL) >= pingtime)
|
||||||
if (time(NULL) >= pingtime)
|
|
||||||
pingstate = P_SENT;
|
pingstate = P_SENT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case P_WAIT: // Syslog('p', "WAIT:");
|
case P_WAIT: if (time(NULL) >= pingtime) {
|
||||||
if (time(NULL) >= pingtime) {
|
|
||||||
pingstate = P_ERROR;
|
pingstate = P_ERROR;
|
||||||
if (icmp_errs < ICMP_MAX_ERRS)
|
if (icmp_errs < ICMP_MAX_ERRS)
|
||||||
Syslog('?', "ping: to %s timeout", pingaddress);
|
Syslog('?', "ping: to %s timeout", pingaddress);
|
||||||
@ -338,8 +334,8 @@ void check_ping(void)
|
|||||||
* Reply received.
|
* Reply received.
|
||||||
*/
|
*/
|
||||||
rc = time(NULL) - (pingtime - 20);
|
rc = time(NULL) - (pingtime - 20);
|
||||||
if (rc > 2)
|
if (rc > 10)
|
||||||
Syslog('p', "ping: reply after %d seconds", rc);
|
Syslog('+', "Ping: slow reply after %d seconds", rc);
|
||||||
pingresult[pingnr] = TRUE;
|
pingresult[pingnr] = TRUE;
|
||||||
if (pingresult[1] || pingresult[2]) {
|
if (pingresult[1] || pingresult[2]) {
|
||||||
if (!internet) {
|
if (!internet) {
|
||||||
@ -362,8 +358,7 @@ void check_ping(void)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case P_SENT: // Syslog('p', "SENT:");
|
case P_SENT: pingtime = time(NULL) + 10; // 10 secs timeout for pause.
|
||||||
pingtime = time(NULL) + 10; // 10 secs timeout for pause.
|
|
||||||
if (pingnr == 1) {
|
if (pingnr == 1) {
|
||||||
pingnr = 2;
|
pingnr = 2;
|
||||||
if (strlen(TCFG.isp_ping2)) {
|
if (strlen(TCFG.isp_ping2)) {
|
||||||
@ -384,7 +379,6 @@ void check_ping(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
pingtime = time(NULL) + 20; // 20 secs timeout for a real ping
|
pingtime = time(NULL) + 20; // 20 secs timeout for a real ping
|
||||||
// Syslog('p', "nr %d address %s", pingnr, pingaddress);
|
|
||||||
if (inet_aton(pingaddress, &paddr)) {
|
if (inet_aton(pingaddress, &paddr)) {
|
||||||
rc = ping_send(paddr);
|
rc = ping_send(paddr);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
@ -402,8 +396,7 @@ void check_ping(void)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case P_ERROR: // Syslog('p', "ERROR:");
|
case P_ERROR: pingresult[pingnr] = FALSE;
|
||||||
pingresult[pingnr] = FALSE;
|
|
||||||
if (pingresult[1] == FALSE && pingresult[2] == FALSE) {
|
if (pingresult[1] == FALSE && pingresult[2] == FALSE) {
|
||||||
icmp_errs++;
|
icmp_errs++;
|
||||||
if (internet) {
|
if (internet) {
|
||||||
|
Reference in New Issue
Block a user