From ad32ba68ff15ee804c92702a80608261eeab5a4c Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Sun, 30 Dec 2001 19:14:55 +0000 Subject: [PATCH] Added callstat timer, updated mbout node info --- mbcico/callstat.c | 61 ++++++++++++++++++++++++++++------------------- mbcico/nlinfo.c | 4 +++- 2 files changed, 39 insertions(+), 26 deletions(-) diff --git a/mbcico/callstat.c b/mbcico/callstat.c index b9ddf4bd..18dc5fe5 100644 --- a/mbcico/callstat.c +++ b/mbcico/callstat.c @@ -39,43 +39,54 @@ callstat *getstatus(faddr *addr) { - static callstat cst; - FILE *fp; + static callstat cst; + FILE *fp; - cst.trytime = 0L; - cst.tryno = 0; - cst.trystat = 0; + cst.trytime = 0L; + cst.tryno = 0; + cst.trystat = 0; - if ((fp = fopen(stsname(addr), "r"))) { - fread(&cst, sizeof(callstat), 1, fp); - fclose(fp); - } + if ((fp = fopen(stsname(addr), "r"))) { + fread(&cst, sizeof(callstat), 1, fp); + fclose(fp); + } - return &cst; + return &cst; } void putstatus(faddr *addr, int incr, int sts) { - FILE *fp; - callstat *cst; + FILE *fp; + callstat *cst; + int j; - cst = getstatus(addr); - if ((fp = fopen(stsname(addr), "w"))) { - if (sts == 0) - cst->tryno = 0; - else - cst->tryno += incr; - cst->trystat = sts; - cst->trytime = time(NULL); - fwrite(cst, sizeof(callstat), 1, fp); - fclose(fp); - if (cst->tryno >= 30) - WriteError("Node %s is marked undialable.", ascfnode(addr, 0x1f)); + cst = getstatus(addr); + if ((fp = fopen(stsname(addr), "w"))) { + if (sts == 0) { + j = cst->tryno = 0; } else { - WriteError("$Cannot create status file for node %s", ascfnode(addr,0x1f)); + cst->tryno += incr; + srand(getpid()); + while (TRUE) { + j = 1+(int) (1.0 * CFG.dialdelay * rand() / (RAND_MAX + 1.0)); + if ((j > (CFG.dialdelay / 10)) && (j > 9)) + break; + } + Syslog('d', "Next call allowed over %d seconds", j); } + + cst->trystat = sts; + cst->trytime = time(NULL) + j; + + fwrite(cst, sizeof(callstat), 1, fp); + fclose(fp); + if (cst->tryno >= 30) + WriteError("Node %s is marked undialable.", ascfnode(addr, 0x1f)); + } else { + WriteError("$Cannot create status file for node %s", ascfnode(addr,0x1f)); + } } diff --git a/mbcico/nlinfo.c b/mbcico/nlinfo.c index d66ab830..3bc7b367 100644 --- a/mbcico/nlinfo.c +++ b/mbcico/nlinfo.c @@ -73,7 +73,9 @@ int nlinfo(faddr *addr) for (i = 0; ikey[i].flag != 0; i++) if ((nlent->iflags & ikey[i].flag) == ikey[i].flag) sprintf(flagbuf + strlen(flagbuf), "%s,", ikey[i].key); - + for (i = 0; okey[i].flag != 0; i++) + if ((nlent->oflags & okey[i].flag) == okey[i].flag) + sprintf(flagbuf + strlen(flagbuf), "%s,", okey[i].key); switch (nlent->xflags) { case RQ_XA: sprintf(flagbuf + strlen(flagbuf), "XA"); break;