Purpose: Makes the timer code more precise. Reasoning: On a UUCP-only box it can actually happen that innd is idle for the whole of five minutes, then it won't notice an expired timer as soon as needed and the next timer log would show a delay which was not there, really. Description: TMRmainloophook() now returns the time until the next timer interval, and this is used to limit the select timeout in CHANreadloop(). Patch against: snapshot 19980530, also tested on snapshot 19980719 diff -ur inn-980530/innd/chan.c inn.danube/innd/chan.c --- inn-980530/innd/chan.c Tue Apr 28 19:12:42 1998 +++ inn.danube/innd/chan.c Sun May 31 12:16:11 1998 @@ -760,12 +760,14 @@ MyRead = RCHANmask; MyWrite = WCHANmask; MyTime = TimeOut; + i = TMRmainloophook(); + if (i) + MyTime.tv_sec = i; TMRstart(TMR_IDLE); count = select(CHANlastfd + 1, &MyRead, &MyWrite, (FDSET *)NULL, &MyTime); TMRstop(TMR_IDLE); - TMRmainloophook(); STATUSmainloophook(); if (GotTerminate) { (void)write(2, EXITING, STRLEN(EXITING)); diff -ur inn-980530/innd/innd.c inn.danube/innd/innd.c --- inn-980530/innd/innd.c Tue May 26 07:12:42 1998 +++ inn.danube/innd/innd.c Sun May 31 19:16:31 1998 @@ -391,7 +391,7 @@ { /* Print i as %d so huge values are real obvious. */ syslog(L_FATAL, "%s cant %s %d bytes %m", LogName, what, i); - exit(1); + abort(); /* NOTREACHED */ } @@ -565,6 +565,7 @@ /* Set defaults. */ TimeOut.tv_sec = DEFAULT_TIMEOUT; + TimeOut.tv_usec = 0; ShouldFork = TRUE; ShouldRenumber = FALSE; ShouldSyntaxCheck = FALSE; diff -ur inn-980530/innd/innd.h inn.danube/innd/innd.h --- inn-980530/innd/innd.h Fri May 22 07:12:33 1998 +++ inn.danube/innd/innd.h Sun May 31 12:16:10 1998 @@ -585,7 +585,7 @@ extern void STATUSmainloophook(void); extern void TMRinit(void); -extern void TMRmainloophook(void); +extern int TMRmainloophook(void); extern void TMRstart(TMRTYPE t); extern void TMRstop(TMRTYPE t); diff -ur inn-980530/innd/timer.c inn.danube/innd/timer.c --- inn-980530/innd/timer.c Thu May 21 07:12:59 1998 +++ inn.danube/innd/timer.c Sun May 31 12:16:11 1998 @@ -112,18 +112,20 @@ } -void TMRmainloophook(void) +int TMRmainloophook(void) { unsigned now; if (!innconf->timer) - return; + return 0; now = gettime(); - if (now - last_summary > (innconf->timer * 1000)) { + if (now - last_summary >= (innconf->timer * 1000)) { dosummary(now - last_summary); last_summary = now; + return 0; } + return innconf->timer - (now - last_summary)/1000; }