From a14e540cd42a397813906b152b9ed3ed26a4d895 Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Sun, 3 Aug 2003 15:58:26 +0000 Subject: [PATCH] Better mbtask logging --- ChangeLog | 1 + mbtask/mbtask.c | 9 +++-- mbtask/ports.c | 17 ++++++-- mbtask/taskstat.c | 101 ++++++++++++++++++++++------------------------ 4 files changed, 68 insertions(+), 60 deletions(-) diff --git a/ChangeLog b/ChangeLog index 03ca8c84..2c05193c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -33,6 +33,7 @@ v0.37.5 12-Jul-2003 Now uses standard locking in ~/var/run When idle, it now reports the time to the next event to be seen in mbmon menu 1. + Remove some semafore debug messages. mbmon: Added program locking, only one mbmon can run at the same time diff --git a/mbtask/mbtask.c b/mbtask/mbtask.c index e52dafac..235cd8ce 100644 --- a/mbtask/mbtask.c +++ b/mbtask/mbtask.c @@ -600,10 +600,11 @@ int checktasks(int onsig) Syslog('+', "Task %s is ready", task[i].name); } else if (WIFSIGNALED(task[i].status)) { rc = WTERMSIG(task[i].status); - if (rc <= 31) - Syslog('+', "Task %s terminated on signal %s (%d)", task[i].name, SigName[rc], rc); - else - Syslog('+', "Task %s terminated with error nr %d", task[i].name, rc); + /* + * 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); diff --git a/mbtask/ports.c b/mbtask/ports.c index d404ffe0..2ce575ca 100644 --- a/mbtask/ports.c +++ b/mbtask/ports.c @@ -113,7 +113,7 @@ void load_ports() FILE *fp; pp_list new; int stdflag; - char *p, *q; + char *p, *q, *capflags; nodelist_modem **tmpm; tidy_portlist(&pl); @@ -136,6 +136,7 @@ void load_ports() memset(&new, 0, sizeof(new)); strncpy(new.tty, ttyinfo.tty, 6); + capflags = xstrcpy((char *)"flags:"); stdflag = TRUE; q = xstrcpy(ttyinfo.flags); for (p = q; p; p = q) { @@ -145,16 +146,24 @@ void load_ports() stdflag = FALSE; } else { for (tmpm = &nl_pots; *tmpm; tmpm=&((*tmpm)->next)) - if (strcasecmp(p, (*tmpm)->name) == 0) + if (strcasecmp(p, (*tmpm)->name) == 0) { new.mflags |= (*tmpm)->value; + capflags = xstrcat(capflags, (char *)" "); + capflags = xstrcat(capflags, (*tmpm)->name); + } for (tmpm = &nl_isdn; *tmpm; tmpm=&((*tmpm)->next)) - if (strcasecmp(p, (*tmpm)->name) == 0) + if (strcasecmp(p, (*tmpm)->name) == 0) { new.dflags |= (*tmpm)->value; + capflags = xstrcat(capflags, (char *)" "); + capflags = xstrcat(capflags, (*tmpm)->name); + } } } - Syslog('p', "port %s modem %08lx ISDN %08lx", new.tty, new.mflags, new.dflags); + Syslog('+', "Found line %s, %s", new.tty, capflags); fill_portlist(&pl, &new); + if (capflags) + free(capflags); } } diff --git a/mbtask/taskstat.c b/mbtask/taskstat.c index 6bab012b..9517b2c5 100644 --- a/mbtask/taskstat.c +++ b/mbtask/taskstat.c @@ -340,8 +340,6 @@ char *getseq(void) int sem_set(char *sem, int value) { - Syslog('s', "%s semafore \"%s\"", value?"Set":"Clear", sem); - if (!strcmp(sem, "scanout")) { s_scanout = value; if (value) @@ -373,77 +371,76 @@ int sem_set(char *sem, int value) char *sem_status(char *data) { - char *cnt, *sem; - static char buf[40]; - int value; + char *cnt, *sem; + static char buf[40]; + int value; - buf[0] = '\0'; - sprintf(buf, "200:1,16;"); - cnt = strtok(data, ","); - sem = strtok(NULL, ";"); + buf[0] = '\0'; + sprintf(buf, "200:1,16;"); + cnt = strtok(data, ","); + sem = strtok(NULL, ";"); - if (!strcmp(sem, "scanout")) { - value = s_scanout; - } else if (!strcmp(sem, "mailout")) { - value = s_mailout; - } else if (!strcmp(sem, "mailin")) { - value = s_mailin; - } else if (!strcmp(sem, "mbindex")) { - value = s_index; - } else if (!strcmp(sem, "newnews")) { - value = s_newnews; - } else if (!strcmp(sem, "msglink")) { - value = s_msglink; - } else if (!strcmp(sem, "reqindex")) { - value = s_reqindex; - } else if (!strcmp(sem, "upsalarm")) { - value = UPSalarm; - } else if (!strcmp(sem, "do_inet")) { - value = s_do_inet; - } else { - Syslog('s', "sem_status(%s) buf=%s", sem, buf); - return buf; - } - - sprintf(buf, "100:1,%s;", value ? "1":"0"); - Syslog('s', "Check semafore \"%s\": %s present", sem, value?"is":"not"); + if (!strcmp(sem, "scanout")) { + value = s_scanout; + } else if (!strcmp(sem, "mailout")) { + value = s_mailout; + } else if (!strcmp(sem, "mailin")) { + value = s_mailin; + } else if (!strcmp(sem, "mbindex")) { + value = s_index; + } else if (!strcmp(sem, "newnews")) { + value = s_newnews; + } else if (!strcmp(sem, "msglink")) { + value = s_msglink; + } else if (!strcmp(sem, "reqindex")) { + value = s_reqindex; + } else if (!strcmp(sem, "upsalarm")) { + value = UPSalarm; + } else if (!strcmp(sem, "do_inet")) { + value = s_do_inet; + } else { + Syslog('s', "sem_status(%s) buf=%s", sem, buf); return buf; + } + + sprintf(buf, "100:1,%s;", value ? "1":"0"); + return buf; } char *sem_create(char *data) { - static char buf[40]; - char *cnt, *sem; + static char buf[40]; + char *cnt, *sem; - cnt = strtok(data, ","); - sem = strtok(NULL, ";"); - buf[0] = '\0'; - sprintf(buf, "200:1,16;"); + cnt = strtok(data, ","); + sem = strtok(NULL, ";"); + buf[0] = '\0'; + sprintf(buf, "200:1,16;"); - if (sem_set(sem, TRUE)) - sprintf(buf, "100:0;"); + if (sem_set(sem, TRUE)) + sprintf(buf, "100:0;"); - return buf; + return buf; } char *sem_remove(char *data) { - static char buf[40]; - char *cnt, *sem; + static char buf[40]; + char *cnt, *sem; - cnt = strtok(data, ","); - sem = strtok(NULL, ";"); - buf[0] = '\0'; - sprintf(buf, "200:1,16;"); + cnt = strtok(data, ","); + sem = strtok(NULL, ";"); + buf[0] = '\0'; + sprintf(buf, "200:1,16;"); - if (sem_set(sem, FALSE)) - sprintf(buf, "100:0;"); + if (sem_set(sem, FALSE)) + sprintf(buf, "100:0;"); - return buf; + return buf; }