Xref: utzoo comp.sys.hp:7926 news.software.nntp:1173 Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!usc!wuarchive!m.cs.uiuc.edu!ibma0.cs.uiuc.edu!ibmb0.cs.uiuc.edu!hull From: hull@ibmb0.cs.uiuc.edu (David Hull) Newsgroups: comp.sys.hp,news.software.nntp Subject: Re: NNTP 1.5.11 under hp-ux...? Message-ID: <27D6AEC4.61CD@ibma0.cs.uiuc.edu> Date: 7 Mar 91 21:21:08 GMT References: <1991Mar05.235630.25240@cs.fau.edu> Sender: news@ibma0.cs.uiuc.edu Organization: University of Illinois at Urbana-Champaign Lines: 146 mahesh@cs.fau.edu (Mahesh Neelakanta) writes: >in server/timer.c : line 123: "timeoutp" is undefined. The code has a variable > called "timeout" under SYSV and "timeoutp" is under bsd. > This is part of the select() call. It appears that whoever hacked in the EXCELAN support broke timer.c for USG systems. Appended are my diffs to timer.c for NNTP 1.5.10 that attempt to make it work for all systems. My assumptions are: EXCELAN's select is severly nonstandard, and uses an integer timeout in microseconds. USG doesn't have fdset, but otherwise select is like Berkeley's. -David Hull *** timer.c- Sat Feb 16 12:06:07 1991 --- timer.c Sun Feb 17 07:00:36 1991 *************** *** 26,32 **** #define FD_ISSET(n, p) ((p)->fds_bits[0] & (1<<(n))) #define FD_ZERO(p) ((p)->fds_bits[0] = 0) #endif ! #endif /* non-portable */ #define BUFFERED_DATA(f) ((f)->_cnt > 0) --- 26,32 ---- #define FD_ISSET(n, p) ((p)->fds_bits[0] & (1<<(n))) #define FD_ZERO(p) ((p)->fds_bits[0] = 0) #endif ! #endif /* non-portable */ #define BUFFERED_DATA(f) ((f)->_cnt > 0) *************** *** 69,82 **** register int i, n; register struct timer *tp; register long secs; - #ifdef USG long timeout; long readfds; #else - register struct timeval *timeoutp; - struct timeval timeout; fd_set readfds; #endif /* No need to do the select if there are characters in the buffer */ if (BUFFERED_DATA(stdin)) --- 69,83 ---- register int i, n; register struct timer *tp; register long secs; long timeout; + #ifdef USG long readfds; #else fd_set readfds; #endif + #ifndef EXCELAN + struct timeval to; + #endif /* No need to do the select if there are characters in the buffer */ if (BUFFERED_DATA(stdin)) *************** *** 83,89 **** return(1); /* Length of next timeout is minimum of all "timers" */ - #ifdef USG timeout = -1; for (i = ntimer, tp = timers; i > 0; --i, ++tp) if (tp->left >= 0 && --- 84,89 ---- *************** *** 93,126 **** /* If active timeouts (this can easily happen), block until input */ if (timeout < 0) timeout = 0; ! #ifdef EXCELAN readfds = 1<<(fileno(stdin)); - timeout = timeout * 1000; /* timeout needs to be in milliseconds */ - #endif /* EXCELAN */ #else - timeout.tv_sec = -1; - timeout.tv_usec = 0; - for (i = ntimer, tp = timers; i > 0; --i, ++tp) - if (tp->left >= 0 && - (tp->left < timeout.tv_sec || timeout.tv_sec < 0)) - timeout.tv_sec = tp->left; - - /* If active timeouts (this can easily happen), block until input */ - if (timeout.tv_sec < 0) - timeoutp = 0; - else - timeoutp = &timeout; - - /* Do select */ FD_ZERO(&readfds); FD_SET(fileno(stdin), &readfds); ! #endif /* !USG */ errno = 0; #ifdef EXCELAN n = select(fileno(stdin) + 1, &readfds, (long*)0, timeout); #else n = select(fileno(stdin) + 1, ! &readfds, (fd_set*)0, (fd_set*)0, timeoutp); #endif /* "Interrupted system call" isn't a real error */ if (n < 0 && errno != EINTR) { --- 93,122 ---- /* If active timeouts (this can easily happen), block until input */ if (timeout < 0) timeout = 0; ! ! #ifdef USG readfds = 1<<(fileno(stdin)); #else FD_ZERO(&readfds); FD_SET(fileno(stdin), &readfds); ! #endif errno = 0; + /* Do select */ #ifdef EXCELAN + timeout *= 1000; /* timeout needs to be in milliseconds */ n = select(fileno(stdin) + 1, &readfds, (long*)0, timeout); #else + to.tv_usec = 0; + to.tv_sec = timeout; + #ifdef USG n = select(fileno(stdin) + 1, ! &readfds, (long*)0, (long*)0, ! (to.tv_sec < 0 ? (struct timeval *)0 : &to)); ! #else ! n = select(fileno(stdin) + 1, ! &readfds, (fd_set*)0, (fd_set*)0, ! (to.tv_sec < 0 ? 0 : &to)); ! #endif #endif /* "Interrupted system call" isn't a real error */ if (n < 0 && errno != EINTR) {