Xref: utzoo gnu.emacs.gnus:1046 news.software.nntp:1030 Path: utzoo!utgpu!watserv1!watmath!uunet!samsung!caen!stealth From: stealth@engin.umich.edu (Mike Pelletier) Newsgroups: gnu.emacs.gnus,news.software.nntp Subject: Re: gnus broken!? Message-ID: <1991Jan3.155148.7471@engin.umich.edu> Date: 3 Jan 91 15:51:48 GMT References: <1990Dec5.181808.10759@mprgate.mpr.ca> Sender: news@engin.umich.edu (CAEN Netnews) Organization: University of Michigan Engineering, Ann Arbor Lines: 163 In article cedman@golem.ps.uci.edu (Carl Edman) writes: >Third: You can really fix the problem by rewriting the timeout parts >of NNTP. If anyone has done this, please let me know. I just replaced the timeout parts of nntp 1.5.10 with the timeout parts of 1.5.9. I have a patch... *** nntp-1.5.10/server/serve.c.orig Sun Aug 12 05:33:30 1990 --- nntp-1.5.10/server/serve.c Fri Sep 7 20:39:42 1990 *************** *** 20,41 **** # endif not USG #endif - #ifdef TIMEOUT - /* Not all systems define these */ - #ifndef FD_SETSIZE - #define FD_SET(n, p) ((p)->fds_bits[0] |= (1<<(n))) - #define FD_CLR(n, p) ((p)->fds_bits[0] &= ~(1<<(n))) - #define FD_ISSET(n, p) ((p)->fds_bits[0] & (1<<(n))) - #define FD_ZERO(p) ((p)->fds_bits[0] = 0) - #endif - #endif - extern int ahbs(), group(), help(), ihave(); extern int list(), newgroups(), newnews(), nextlast(), post(); extern int slave(), stat(), xhdr(); - extern int errno; - #ifdef AUTH extern int doauth(); #endif AUTH --- 20,29 ---- *************** *** 107,116 **** #ifdef POSTER struct passwd *pp; #endif ! #ifdef TIMEOUT ! struct timeval timeout; ! fd_set readfds; ! #endif #ifdef LOG # ifdef USG struct tms cpu; --- 95,103 ---- #ifdef POSTER struct passwd *pp; #endif ! # ifdef TIMEOUT ! void timeout(); ! # endif #ifdef LOG # ifdef USG struct tms cpu; *************** *** 249,286 **** */ #ifdef TIMEOUT ! timeout.tv_sec = TIMEOUT; ! timeout.tv_usec = 0; ! #endif ! for (;;) { #ifdef TIMEOUT ! /* Do timeout with select() (i.e. the intelligent way) */ ! FD_ZERO(&readfds); ! FD_SET(fileno(stdin), &readfds); ! errno = 0; ! i = select(fileno(stdin) + 1, ! &readfds, (fd_set*)0, (fd_set*)0, &timeout); ! if (i < 0) { ! /* "Interrupted system call" isn't a real error */ ! if (errno == EINTR) ! continue; ! syslog(LOG_ERR, "%s read select: %m", hostname); ! break; ! } ! if (!FD_ISSET(fileno(stdin), &readfds)) { ! printf( ! "%d Timeout after %d seconds, closing connection.\r\n", ! ERR_FAULT, TIMEOUT); ! (void) fflush(stdout); - #ifdef LOG - syslog(LOG_ERR, "%s timeout", hostname); - #endif LOG - exit(1); - } - #endif - if (fgets(line, sizeof(line), stdin) == NULL) - break; /* Strip trailing CR-LF */ cp = line + strlen(line) - 1; while (cp >= line && (*cp == '\n' || *cp == '\r')) --- 236,250 ---- */ #ifdef TIMEOUT ! (void) signal(SIGALRM, timeout); ! (void) alarm(TIMEOUT); ! #endif TIMEOUT ! ! while (fgets(line, sizeof(line), stdin) != NULL) { #ifdef TIMEOUT ! (void) alarm(0); ! #endif TIMEOUT /* Strip trailing CR-LF */ cp = line + strlen(line) - 1; while (cp >= line && (*cp == '\n' || *cp == '\r')) *************** *** 322,327 **** --- 286,294 ---- (void) fflush(stdout); } } + #ifdef TIMEOUT + (void) alarm(TIMEOUT); + #endif TIMEOUT } printf("%d %s closing connection. Goodbye.\r\n", *************** *** 393,395 **** --- 360,384 ---- #endif exit(0); } + + + #ifdef TIMEOUT + /* + * No activity for TIMEOUT seconds, so print an error message + * and close the connection. + */ + + void + timeout() + { + printf("%d Timeout after %d seconds, closing connection.\r\n", + ERR_FAULT, TIMEOUT); + (void) fflush(stdout); + + #ifdef LOG + syslog(LOG_ERR, "%s timeout", hostname); + #endif LOG + + exit(1); + } + #endif TIMEOUT ----------------------------- This is what I'm running now, and I've had no problems for months. -- Mike Pelletier - Usenet News Admin & Programmer "Wind, waves, etc. are breakdowns in the face of the commitment to getting from here to there. But they are the conditions for sailing -- not something to be gotten rid of, but something to be danced with."