sob@watson.bcm.tmc.edu (Stan Barber) (09/19/88)
If you are trying to use nntp on a machine that does not use the DBM-style history file format, this is a MANDITORY patch. Also, for systems that have the ustat() system call, it will provide a way for nntp to know when your news spool file system is filling up and keep you from losing incoming news due to lack of disk space. This is an official patch to nntp 1.5. This is patch #3. If you need the previous two patches, you can retreive them from the archive server at bcm.tmc.edu. Send a message containing the subject line "help" to archive-server@bcm.tmc.edu for more information. Description: 1. Under the history mechanism that does not use DBM, files are not closed following use. This causes the process to run of file descriptors & nntpd to abort. The nntp log file will show this with "No more files" messages. 2. There was no graceful way for any version of nntp to stop a transfer when there was no space left in the news SPOOLDIR. This can cause many aborted connections and sometimes lost news Repeat by: 1. Make nntpd for a system that does not use the DBM form of the history file. Watch the nntp log during a large transfer of articles from another feed site. Notice the "No more files" messages after about 20 articles transfer. 2. Fill up the news SPOOLDIR and then watch the nntp log file as more articles come in. Fix: Apply the following patches after you have change directory to nntp.1.5. Then rebuild nntpd and reinstall. To use the space detection feature, you must have MINFREE defined in defs.h of your _news_ sources. News 2.11 is assumed to be your current release of netnews. Index: server/misc.c *** server/misc.c Fri May 6 18:36:16 1988 --- ../../nntp_gazette/server/misc.c Sun Sep 18 20:57:51 1988 *************** *** 218,224 **** (void) strcpy(path, spooldir); (void) strcat(path, "/"); (void) strcat(path, tmp); ! return (path); } --- 218,226 ---- (void) strcpy(path, spooldir); (void) strcat(path, "/"); (void) strcat(path, tmp); ! #ifdef USGHIST ! (void) fclose(hfp); ! #endif return (path); } *************** *** 583,588 **** --- 585,591 ---- } #endif USGHIST #ifdef USG + #ifndef GAZETTE bcopy(s, d, l) register char *s, *d; register int l; *************** *** 613,618 **** --- 616,622 ---- while (l-- > 0) *p++ = 0; } + #endif dup2(x,y) int x,y; *************** *** 619,623 **** --- 623,647 ---- { close(y); return(fcntl(x, F_DUPFD,y )); + } + + #include <ustat.h> + /* + * determine if there is enough free space on the device + * return 0 if there is and + * anything appropriate if there is not + * written by Stan Barber (sob@soma.bcm.tmc.edu) + */ + int + space() + { + struct stat file; + struct ustat device; + if (stat(SPOOLDIR,&file)) + return(-1); /* can't stat spool */ + if (ustat(file.st_dev, &device)) + return(-2); /* can't stat the device */ + if(device.f_tfree < MINFREE) return(-3); + return(0); } #endif USG Index: server/main.c *** server/main.c Fri May 6 18:36:15 1988 --- ../../nntp_gazette/server/main.c Sun Sep 18 20:58:25 1988 *************** *** 33,38 **** --- 33,43 ---- /* fd 0-2 should be open and point to / now. */ + /* Let's close all the other FD's just to be sure */ + for(sockt = 3; sockt < 40; sockt++) + (void) close(sockt); + + #ifndef FAKESYSLOG #ifdef SYSLOG #ifdef BSD_42 openlog("nntpd", LOG_PID); /* fd 3 */ *************** *** 40,45 **** --- 45,51 ---- openlog("nntpd", LOG_PID, SYSLOG); /* fd 3 */ #endif #endif + #endif #ifdef FASTFORK num_groups = read_groups(); /* Read active file now (fd 4) */ *************** *** 71,78 **** continue; #ifdef USG (void) signal(SIGCLD, SIG_IGN); ! #endif bzero((char *)&from,sizeof(from)); client = accept(sockt, &from); #else length = sizeof (from); --- 77,86 ---- continue; #ifdef USG (void) signal(SIGCLD, SIG_IGN); ! memset((char *)&from,'\0',sizeof(from)); ! #else bzero((char *)&from,sizeof(from)); + #endif client = accept(sockt, &from); #else length = sizeof (from); *************** *** 109,115 **** --- 117,128 ---- #ifdef EXCELAN if (fork()) exit(0); + #ifdef USG + (void * )memcpy(¤t_peer,&from, + sizeof(from)); + #else bcopy(&from,¤t_peer,sizeof(from)); + #endif make_stdio(sockt); #else (void) close(sockt); Index: server/serve.c *** server/serve.c Fri May 6 18:36:17 1988 --- ../../nntp_gazette/server/serve.c Sun Sep 18 20:59:02 1988 *************** *** 74,79 **** --- 74,81 ---- double user, sys; #ifdef USG time_t start, finish; + extern int space(); + int out_of_space; #else not USG struct timeval start, finish; #endif not USG *************** *** 103,114 **** /* If we're ALONE, then we've already opened syslog */ ! #ifndef ALONE ! # ifdef SYSLOG ! # ifdef BSD_42 openlog("nntpd", LOG_PID); ! # else openlog("nntpd", LOG_PID, SYSLOG); # endif # endif #endif --- 105,118 ---- /* If we're ALONE, then we've already opened syslog */ ! #ifndef FAKESYSLOG ! # ifndef ALONE ! # ifdef SYSLOG ! # ifdef BSD_42 openlog("nntpd", LOG_PID); ! # else openlog("nntpd", LOG_PID, SYSLOG); + # endif # endif # endif #endif *************** *** 140,145 **** --- 144,162 ---- exit(1); } + #ifdef USG + if (space() < 0 && !canpost ) { + printf("%d %s NNTP server out of space. Try later.\r\n", + ERR_FAULT, host); + (void) fflush(stdout); + #ifdef LOG + syslog(LOG_INFO, "%s no space", hostname); + #endif + exit(1); + } + out_of_space = 0; + #endif + /* If we can talk, proceed with initialization */ ngpermcount = get_nglist(&ngpermlist, gdbuf); *************** *** 209,214 **** --- 226,237 ---- *cp = '\0'; } + #ifdef USG + if (space() < 0 && !canpost ) { + out_of_space++; + break; + } + #endif if ((argnum = parsit(line, &argp)) == 0) continue; /* Null command */ else { *************** *** 235,243 **** #endif TIMEOUT } ! printf("%d %s closing connection. Goodbye.\r\n", OK_GOODBYE, host); ! (void) fflush(stdout); #ifdef LOG if (ferror(stdout)) --- 258,276 ---- #endif TIMEOUT } ! #ifdef USG ! if(out_of_space) { ! printf("%d %s NNTP server out of space. Quitting.\r\n", ! ERR_GOODBYE, host); ! #ifdef LOG ! syslog(LOG_INFO, "%s no space", hostname); ! #endif ! } else ! #endif ! printf("%d %s closing connection. Goodbye.\r\n", ! OK_GOODBYE, host); + (void) fflush(stdout); #ifdef LOG if (ferror(stdout)) Index: common/version.c *** common/version.c Thu Feb 25 22:02:33 1988 --- ../../nntp_gazette/common/version.c Sun Sep 18 21:03:06 1988 *************** *** 2,5 **** * Provide the version number of this release. */ ! char nntp_version[] = "1.5 (26 Feb 88)"; --- 2,5 ---- * Provide the version number of this release. */ ! char nntp_version[] = "1.5.3 (18 Sep 88)"; Stan internet: sob@bcm.tmc.edu Baylor College of Medicine Olan uucp: {rice,killer,hoptoad}!academ!sob Barber Opinions expressed are only mine.