Added callstat timer, updated mbout node info

This commit is contained in:
Michiel Broek 2001-12-30 19:14:55 +00:00
parent 80cd689c19
commit ad32ba68ff
2 changed files with 39 additions and 26 deletions

View File

@ -39,43 +39,54 @@
callstat *getstatus(faddr *addr) callstat *getstatus(faddr *addr)
{ {
static callstat cst; static callstat cst;
FILE *fp; FILE *fp;
cst.trytime = 0L; cst.trytime = 0L;
cst.tryno = 0; cst.tryno = 0;
cst.trystat = 0; cst.trystat = 0;
if ((fp = fopen(stsname(addr), "r"))) { if ((fp = fopen(stsname(addr), "r"))) {
fread(&cst, sizeof(callstat), 1, fp); fread(&cst, sizeof(callstat), 1, fp);
fclose(fp); fclose(fp);
} }
return &cst; return &cst;
} }
void putstatus(faddr *addr, int incr, int sts) void putstatus(faddr *addr, int incr, int sts)
{ {
FILE *fp; FILE *fp;
callstat *cst; callstat *cst;
int j;
cst = getstatus(addr); cst = getstatus(addr);
if ((fp = fopen(stsname(addr), "w"))) { if ((fp = fopen(stsname(addr), "w"))) {
if (sts == 0) if (sts == 0) {
cst->tryno = 0; j = 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));
} else { } 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));
}
} }

View File

@ -73,7 +73,9 @@ int nlinfo(faddr *addr)
for (i = 0; ikey[i].flag != 0; i++) for (i = 0; ikey[i].flag != 0; i++)
if ((nlent->iflags & ikey[i].flag) == ikey[i].flag) if ((nlent->iflags & ikey[i].flag) == ikey[i].flag)
sprintf(flagbuf + strlen(flagbuf), "%s,", ikey[i].key); 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) { switch (nlent->xflags) {
case RQ_XA: sprintf(flagbuf + strlen(flagbuf), "XA"); break; case RQ_XA: sprintf(flagbuf + strlen(flagbuf), "XA"); break;