ANU News Patch Patch ID: 930723_nntp_server.c!saul@hnrc.tufts.edu Date: 23-Jul-1993 Author: Saul Tannenbaum saul@hnrc.tufts.edu News Version: 6.1beta7 News Files: NNTP_Server.C, NewsSite.H Description: Performance enhancements for the nntp server: 1) The incoming news .batch file is pre-extended contiguous-best-try 2) The close/re-open cycle of the .batch file is replaced with an fflush/fsync operation which preserves reliability with lower overhead 3) Modest multi-block counts are added to all open calls 4) Multi-buffering and read-ahead/write-behind is turned on for all opens that seem as if they might generate substantial I/O 5) Whenever possible, estimates are made for the size of created files and those files are pre-extended. Modest default extension quantities are also used. 6) NEWSSITE.H is used for customizing compile time constants. 7) NNTP version identification is bumped to 6.1.1 to distinguish these functional changes *** nntp_server.c --- nntp_server_new.c ************** *** 227,232 /* provide a fake definition of newscmd and the CLI tables are not required, but are referenced in newsvariables.h */ #if vax11c globaldef int newscmd; #else --- 227,234 ----- /* provide a fake definition of newscmd and the CLI tables are not required, but are referenced in newsvariables.h */ + #include "newssite.h" /* 7/16/93 - saul@hnrc.tufts.edu - move all customizing + defines into one file */ #if vax11c globaldef int newscmd; #else ************** *** 233,244 void newscmd() {} #endif - /* NEWS and NNTP version identification */ - #define nntp_version "6.1" - /* set to 1 to produce LOGGING output - to logical NEWS_NNTP_LOG file */ - #define LOGGING 1 - #define LOG_TABLE "LNM$SYSTEM" #define ALQ_NONDEF 0 #define LEAVE_SPOOL_OPEN 0 --- 235,240 ----- void newscmd() {} #endif #define CLOSE_LINK 0 /* Status flags passed between server and driver */ #define NO_INPUT 0 ************** *** 240,261 #define LOGGING 1 #define LOG_TABLE "LNM$SYSTEM" - #define ALQ_NONDEF 0 - #define LEAVE_SPOOL_OPEN 0 - - - #if ALQ_NONDEF - #define OPEN_MODE "w","alq=30","deq=30" - #else - #define OPEN_MODE "w" - #endif - - #define ALWAYS_SPOOL 0 /* set to 1 to spool ALL POST items - other spool only Control items */ - - /* file names */ - #define NEWSBATCH "NEWS_MANAGER:NNTP_%s_%X.BATCH" - #define NEWS_BATCH_SIZE 250000 - #define CLOSE_LINK 0 /* Status flags passed between server and driver */ #define NO_INPUT 0 #define CMD_INPUT 1 --- 236,241 ----- #endif #define CLOSE_LINK 0 /* Status flags passed between server and driver */ #define NO_INPUT 0 #define CMD_INPUT 1 ************** *** 326,332 DIST_ENTRY_T *distfile = 0; /* server response table */ ! static char *msg[] = {"100 help text follows\r\n", "199 debug output\r\n", "200 ANU NEWS/NNTP server %s (V%s). Ready at %s (%s).\r\n", --- 306,312 ----- DIST_ENTRY_T *distfile = 0; /* server response table */ ! static const char *msg[] = {"100 help text follows\r\n", "199 debug output\r\n", "200 ANU NEWS/NNTP server %s (V%s). Ready at %s (%s).\r\n", ************** *** 371,377 "481 Requested Fields not defined on server.\r\n", ".\r\n"}; ! static char *help_cmds[] = { "ARTICLE Send article referenced by id.\r\n", "ARTICLE Send article, number from current newsgroup.\r\n", --- 351,357 ----- "481 Requested Fields not defined on server.\r\n", ".\r\n"}; ! static const char *help_cmds[] = { "ARTICLE Send article referenced by id.\r\n", "ARTICLE Send article, number from current newsgroup.\r\n", ************** *** 462,471 total_bytes_received = 0, total_elapsed_time = 0; ! #if LEAVE_SPOOL_OPEN ! static ! FILE *fpb = 0; ! #endif sysprv() { --- 442,448 ----- total_bytes_received = 0, total_elapsed_time = 0; ! static FILE *fpb = 0; sysprv() { ************** *** 514,520 char filename[FILE_STRLEN]; sprintf(filename,scratchfile,getpid(),stm); ! return(fopen(filename,"w")); } /* --- 491,497 ----- char filename[FILE_STRLEN]; sprintf(filename,scratchfile,getpid(),stm); ! return(fopen(filename,"w","mbc=16","mbf=2","alq=100","deq=16","rop=wbh")); } /* ************** *** 532,538 FILE *fpr; *mail_rtn = '\0'; ! if (!(fpr = fopen(MAILPATHS_FILE,"r"))) return(mail_rtn); while (fgets(inpline,sizeof(inpline),fpr)) { if (*inpline == '#') continue; lower_case(inpline); --- 509,515 ----- FILE *fpr; *mail_rtn = '\0'; ! if (!(fpr = fopen(MAILPATHS_FILE,"r","mbc=16"))) return(mail_rtn); while (fgets(inpline,sizeof(inpline),fpr)) { if (*inpline == '#') continue; lower_case(inpline); ************** *** 590,596 #define MAX_UNK 50 ! static char *header_keyw[] = { "path", "newsgroups", --- 567,573 ----- #define MAX_UNK 50 ! static const char *header_keyw[] = { "path", "newsgroups", ************** *** 852,858 *cp1, *cp2; ! if (fpr = fopen(ccfile,"r")) { while (fgets(xfrbuf,sizeof(xfrbuf),fpr)) { if (cp1 = strchr(xfrbuf,'#')) *cp1 = '\0'; if (cp1 = strchr(xfrbuf,'\n')) *cp1 = '\0'; --- 829,835 ----- *cp1, *cp2; ! if (fpr = fopen(ccfile,"r","mbc=16")) { while (fgets(xfrbuf,sizeof(xfrbuf),fpr)) { if (cp1 = strchr(xfrbuf,'#')) *cp1 = '\0'; if (cp1 = strchr(xfrbuf,'\n')) *cp1 = '\0'; ************** *** 916,922 strcat(locgrp,*groups); strcat(locgrp,","); ! if (!(fpr = fopen("NEWS_MANAGER:NEWS_POST.DEFAULTS","r"))) { free(locgrp); free(locdst); free(locfol); --- 893,899 ----- strcat(locgrp,*groups); strcat(locgrp,","); ! if (!(fpr = fopen("NEWS_MANAGER:NEWS_POST.DEFAULTS","r","mbc=16"))) { free(locgrp); free(locdst); free(locfol); ************** *** 1051,1057 if (getgroupbyname(s)) { nowrite_acc = (newsgrp.grp_flags & NEWS_M_NOWRITE_SET); sprintf(itm_fname,Access_template,util_dir(newsgrp.grp_name)); ! if (fpd = fopen(itm_fname,"r")) { while (fgets(acline,sizeof(acline),fpd)) { if (*acline == '#') continue; if (cp = strchr(acline,'\n')) *cp = ' '; --- 1028,1034 ----- if (getgroupbyname(s)) { nowrite_acc = (newsgrp.grp_flags & NEWS_M_NOWRITE_SET); sprintf(itm_fname,Access_template,util_dir(newsgrp.grp_name)); ! if (fpd = fopen(itm_fname,"r","mbc=16")) { while (fgets(acline,sizeof(acline),fpd)) { if (*acline == '#') continue; if (cp = strchr(acline,'\n')) *cp = ' '; ************** *** 1116,1122 strcpy(no_new_item,"Input file is empty"); return(1); } ! if (!(ifile = fopen(fnam,"r"))) { strcpy(no_new_item,"Cannot open input file (read access)"); return(1); } --- 1093,1099 ----- strcpy(no_new_item,"Input file is empty"); return(1); } ! if (!(ifile = fopen(fnam,"r","mbc=16","mbf=2","rop=rah"))) { strcpy(no_new_item,"Cannot open input file (read access)"); return(1); } ************** *** 1207,1212 if (!*itm_fname) { int header = 1; sprintf(itm_fname,Itm_template,util_dir(newsgrp.grp_name),cre_itm[i]); if (!(ofile = fopen(itm_fname,"w"))) { strcpy(no_new_item,"Cannot open output file (write access)"); --- 1184,1195 ----- if (!*itm_fname) { int header = 1; + /* 7/21/93 saul@hnrc.tufts.edu - calculate approximate output size + based upon the size in bytes of the input file and pre-extend the file */ + + char alloc_size[32]; + sprintf (alloc_size, "alq=%d", ((sbuffer.st_size+511)/512)); + sprintf(itm_fname,Itm_template,util_dir(newsgrp.grp_name),cre_itm[i]); if (!(ofile = fopen(itm_fname,"w", alloc_size,"deq=16","fop=cbt,tef","rop=wbh","mbc=16","mbf=2"))) { ************** *** 1208,1214 int header = 1; sprintf(itm_fname,Itm_template,util_dir(newsgrp.grp_name),cre_itm[i]); ! if (!(ofile = fopen(itm_fname,"w"))) { strcpy(no_new_item,"Cannot open output file (write access)"); status = 1; *itm_fname = '\0'; --- 1191,1198 ----- sprintf (alloc_size, "alq=%d", ((sbuffer.st_size+511)/512)); sprintf(itm_fname,Itm_template,util_dir(newsgrp.grp_name),cre_itm[i]); ! if (!(ofile = fopen(itm_fname,"w", ! alloc_size,"deq=16","fop=cbt,tef","rop=wbh","mbc=16","mbf=2"))) { strcpy(no_new_item,"Cannot open output file (write access)"); status = 1; *itm_fname = '\0'; ************** *** 1413,1418 int approval_required = 0, posted = 0, cur_time; struct tm *stme; time(&cur_time); p = ctime(&cur_time); --- 1397,1403 ----- int approval_required = 0, posted = 0, cur_time; struct tm *stme; + struct stat stat_buffer; time(&cur_time); p = ctime(&cur_time); ************** *** 1428,1434 unk_index = 0; if (!*filename) { /* dump the buffer to a file */ ! if (!(fpw = fopen(scrfile,"w"))) { sprintf(msg,"Scratch file %s: %s",scrfile,strerror(errno,vaxc$errno)); return(0); } --- 1413,1419 ----- unk_index = 0; if (!*filename) { /* dump the buffer to a file */ ! if (!(fpw = fopen(scrfile,"w","alq=16","deq=16","mbc=16","mbf=2","rop=wbh"))) { sprintf(msg,"Scratch file %s: %s",scrfile,strerror(errno,vaxc$errno)); return(0); } ************** *** 1438,1444 } *msg = '\0'; ! if (!(fpr = fopen(filename,"r"))) { sprintf(msg,"Post file %s: %s",scrfile,strerror(errno,vaxc$errno)); return(0); } --- 1423,1429 ----- } *msg = '\0'; ! if (!(fpr = fopen(filename,"r","mbc=16","mbf=2","rop=rah"))) { sprintf(msg,"Post file %s: %s",scrfile,strerror(errno,vaxc$errno)); return(0); } ************** *** 1448,1453 while (!strchr(xfrbuf,'\n') && fgets(xfrbuf,sizeof(xfrbuf),fpr)); } fseek(fpr,0,0); while (fgets(xfrbuf,sizeof(xfrbuf),fpr)) { if (*xfrbuf == '\n') break; --- 1433,1441 ----- while (!strchr(xfrbuf,'\n') && fgets(xfrbuf,sizeof(xfrbuf),fpr)); } fseek(fpr,0,0); + /* save the size for pre-extending the output file + saul@hnrc.tufts.edu 7/22/93 */ + fstat (fileno(fpr), &stat_buffer); while (fgets(xfrbuf,sizeof(xfrbuf),fpr)) { if (*xfrbuf == '\n') break; ************** *** 1524,1531 get_post_defaults(&newsgroups_header,&distribution_header,&followup_to_header); mail_add_expiry = parse_expiry_date(expires_header); ! ! fpw = fopen(scrfile,"w"); fprintf(fpw,"Relay-Version: %s %s VAX/VMS; site %s\n", NEWS_VERSION,NEWS_DDATE,Node_address); --- 1512,1525 ----- get_post_defaults(&newsgroups_header,&distribution_header,&followup_to_header); mail_add_expiry = parse_expiry_date(expires_header); ! { ! /* open the file and prextend it to the size of existing file ! saul@hnrc.tufts.edu 7/22/93 */ ! char* alloc_size[32]; ! sprintf(alloc_size,"alq=%d",((stat_buffer.st_size+511)/512)); ! fpw = fopen(scrfile,"w",alloc_size,"deq=16","fop=cbt,tef","mbc=16","mbf=2", ! "rop=wbh"); ! } fprintf(fpw,"Relay-Version: %s %s VAX/VMS; site %s\n", NEWS_VERSION,NEWS_DDATE,Node_address); ************** *** 1612,1618 } else { if (control_header || ALWAYS_SPOOL) { ! posted = spool_add_item(scrfile,0,msg,stm); } else { if (!sys_local_accept(newsgroups_header,distribution_header)) --- 1606,1612 ----- } else { if (control_header || ALWAYS_SPOOL) { ! posted = spool_add_item(scrfile,0,msg,stm,POST); } else { if (!sys_local_accept(newsgroups_header,distribution_header)) ************** *** 1641,1647 * spool_add_item * */ ! spool_add_item(filename,buf,msg,stm) char *filename; /* name of temp file containing article (1st char NUL if none) */ char *buf; /* ptr to article in memory (only used if no temp file) */ char *msg; /* where to store an error message */ --- 1635,1641 ----- * spool_add_item * */ ! spool_add_item(filename,buf,msg,stm,mode) char *filename; /* name of temp file containing article (1st char NUL if none) */ char *buf; /* ptr to article in memory (only used if no temp file) */ char *msg; /* where to store an error message */ ************** *** 1646,1651 char *buf; /* ptr to article in memory (only used if no temp file) */ char *msg; /* where to store an error message */ int stm; { static char batch[FILE_STRLEN] = ""; --- 1640,1648 ----- char *buf; /* ptr to article in memory (only used if no temp file) */ char *msg; /* where to store an error message */ int stm; + int mode; /* POST - we're spooling a posting + FEED - we're spooling a newsfeed - used only to + estimate spool file size */ { static char batch[FILE_STRLEN] = ""; int max_batch = 0; ************** *** 1648,1654 int stm; { static char batch[FILE_STRLEN] = ""; ! char xfrbuf[IO_SIZE]; FILE *fpr = 0; #if !LEAVE_SPOOL_OPEN --- 1645,1652 ----- estimate spool file size */ { static char batch[FILE_STRLEN] = ""; ! int max_batch = 0; ! char *batch_logical = NULL; char xfrbuf[IO_SIZE]; FILE *fpr = 0; ************** *** 1651,1659 char xfrbuf[IO_SIZE]; FILE *fpr = 0; - #if !LEAVE_SPOOL_OPEN - FILE *fpb; - #endif if (filename && *filename) { if (!(fpr = fopen(filename,"r"))) { --- 1649,1654 ----- char *batch_logical = NULL; char xfrbuf[IO_SIZE]; FILE *fpr = 0; if (filename && *filename) { if (!(fpr = fopen(filename,"r","mbc=16","mbf=2","rop=rah"))) { ************** *** 1656,1662 #endif if (filename && *filename) { ! if (!(fpr = fopen(filename,"r"))) { sprintf(msg,"Temp %s: %s",filename,strerror(errno,vaxc$errno)); return(0); } --- 1651,1657 ----- FILE *fpr = 0; if (filename && *filename) { ! if (!(fpr = fopen(filename,"r","mbc=16","mbf=2","rop=rah"))) { sprintf(msg,"Temp %s: %s",filename,strerror(errno,vaxc$errno)); return(0); } ************** *** 1661,1666 return(0); } } #if LEAVE_SPOOL_OPEN if (fpb && (batch_size > NEWS_BATCH_SIZE)) { --- 1656,1666 ----- return(0); } } + if (mode == FEED) /* if we're spooling an incoming newsfeed, calculate + the batch size */ + { + if ((batch_logical = getenv("NEWS_BATCH_SIZE")) != NULL) + sscanf(batch_logical,"%d",&max_batch); if (max_batch == 0) { ************** *** 1662,1669 } } ! #if LEAVE_SPOOL_OPEN ! if (fpb && (batch_size > NEWS_BATCH_SIZE)) { fclose(fpb); fpb = 0; } --- 1662,1688 ----- if ((batch_logical = getenv("NEWS_BATCH_SIZE")) != NULL) sscanf(batch_logical,"%d",&max_batch); ! if (max_batch == 0) ! { ! max_batch = NEWS_BATCH_SIZE; ! } ! else if (max_batch < NEWS_BATCH_SIZE_LOWLIM) ! { ! max_batch = NEWS_BATCH_SIZE_LOWLIM; ! } ! else if (max_batch > NEWS_BATCH_SIZE_HIGHLIM) ! { ! max_batch = NEWS_BATCH_SIZE_HIGHLIM; ! } ! ! } ! else /* otherwise, we're spooling a single posting, so use a ! more conservative size */ ! { ! max_batch = NEWS_BATCH_SIZE_LOWLIM; ! } ! ! if (fpb && (batch_size > max_batch)) { fclose(fpb); fpb = 0; } ************** *** 1668,1673 fpb = 0; } if (!fpb) { sprintf(batch,NEWSBATCH,time_str(),getpid()); fpb = fopen(batch,OPEN_MODE); batch_size = 0; --- 1687,1694 ----- fpb = 0; } if (!fpb) { + char alloc_size[32]; + sprintf (alloc_size, "alq=%d", (max_batch+511)/512); sprintf(batch,NEWSBATCH,time_str(),getpid()); fpb = fopen(batch, "w",alloc_size,"deq=100","fop=cbt","rop=wbh","mbc=32","mbf=2"); ************** *** 1669,1675 } if (!fpb) { sprintf(batch,NEWSBATCH,time_str(),getpid()); ! fpb = fopen(batch,OPEN_MODE); batch_size = 0; } #else --- 1690,1697 ----- char alloc_size[32]; sprintf (alloc_size, "alq=%d", (max_batch+511)/512); sprintf(batch,NEWSBATCH,time_str(),getpid()); ! fpb = fopen(batch, ! "w",alloc_size,"deq=100","fop=cbt","rop=wbh","mbc=32","mbf=2"); batch_size = 0; } ************** *** 1672,1679 fpb = fopen(batch,OPEN_MODE); batch_size = 0; } - #else - if (!*batch) sprintf(batch,NEWSBATCH,time_str(),getpid()); if (!*batch || (batch_size > NEWS_BATCH_SIZE) || !(fpb = fopen(batch,"a"))) { sprintf(batch,NEWSBATCH,time_str(),getpid()); --- 1694,1699 ----- "w",alloc_size,"deq=100","fop=cbt","rop=wbh","mbc=32","mbf=2"); batch_size = 0; } if (!fpb) { if (fpr) fclose(fpr); ************** *** 1675,1687 #else if (!*batch) sprintf(batch,NEWSBATCH,time_str(),getpid()); - if (!*batch || (batch_size > NEWS_BATCH_SIZE) || !(fpb = fopen(batch,"a"))) { - sprintf(batch,NEWSBATCH,time_str(),getpid()); - fpb = fopen(batch,OPEN_MODE); - batch_size = 0; - } - #endif - if (!fpb) { if (fpr) fclose(fpr); sprintf(msg,"Batch %s: %s",batch,strerror(errno,vaxc$errno)); --- 1695,1700 ----- batch_size = 0; } if (!fpb) { if (fpr) fclose(fpr); sprintf(msg,"Batch %s: %s",batch,strerror(errno,vaxc$errno)); ************** *** 1695,1703 else fputs(buf,fpb); batch_size += ihave_size; ! #if !LEAVE_SPOOL_OPEN ! fclose(fpb); ! #endif strcpy(msg,"Item successfully spooled."); return(1); } --- 1708,1717 ----- else fputs(buf,fpb); batch_size += ihave_size; ! if (getenv("NEWS_BATCH_FLUSH_DISABLE") == NULL) { ! fflush (fpb); ! fsync(fileno (fpb)); ! } strcpy(msg,"Item successfully spooled."); return(1); } ************** *** 1725,1731 } else *filename = '\0'; if (mode == POST) retval = post_add_item(filename,buf,msgbuf,stm); ! else retval = spool_add_item(filename,buf,msgbuf,stm); if (*filename) while (!delete(filename)); return(retval); } --- 1739,1745 ----- } else *filename = '\0'; if (mode == POST) retval = post_add_item(filename,buf,msgbuf,stm); ! else retval = spool_add_item(filename,buf,msgbuf,stm,FEED); if (*filename) while (!delete(filename)); return(retval); } ************** *** 1934,1940 if (!(newsgrp.grp_flags & NEWS_M_RESTRICT_SET)) return(1); sprintf(itm_fname,Access_template,util_dir(newsgrp.grp_name)); ! if (fpd = fopen(itm_fname,"r")) { read_access = 0; while (fgets(acline,sizeof(acline),fpd)) { if (*acline == '#') continue; --- 1948,1954 ----- if (!(newsgrp.grp_flags & NEWS_M_RESTRICT_SET)) return(1); sprintf(itm_fname,Access_template,util_dir(newsgrp.grp_name)); ! if (fpd = fopen(itm_fname,"r","mbc=16")) { read_access = 0; while (fgets(acline,sizeof(acline),fpd)) { if (*acline == '#') continue; ************** *** 2021,2027 strcpy(gdlist,"*"); *canread = *canpost = *canxfr = 0; ! if (!(acs_fp = fopen(NNTP_ACCESS_FILE,"r"))) { *canread = *canpost = *canxfr = 1; return; } --- 2035,2041 ----- strcpy(gdlist,"*"); *canread = *canpost = *canxfr = 0; ! if (!(acs_fp = fopen(NNTP_ACCESS_FILE,"r","mbc=16"))) { *canread = *canpost = *canxfr = 1; return; } ************** *** 2221,2227 if (!(sys$get(&grprab) & 1)) return(0); } sprintf(itm_fname,Itm_template,util_dir(newsgrp.grp_name),newsitm.itm_num); ! if (!(fpr = fopen(itm_fname,"r"))) return(0); while (fgets(buf,sizeof(buf),fpr)) { if ((c = *buf) == '\n') break; if ((c != 'd') && (c != 'D')) continue; --- 2235,2241 ----- if (!(sys$get(&grprab) & 1)) return(0); } sprintf(itm_fname,Itm_template,util_dir(newsgrp.grp_name),newsitm.itm_num); ! if (!(fpr = fopen(itm_fname,"r","mbc=16"))) return(0); while (fgets(buf,sizeof(buf),fpr)) { if ((c = *buf) == '\n') break; if ((c != 'd') && (c != 'D')) continue; ************** *** 2294,2300 if (no_open_file) return(1); sprintf(itm_fname,Itm_template,util_dir(newsgrp.grp_name),newsitm.itm_num); ! return(fopen(itm_fname,"r")); } /* --- 2308,2314 ----- if (no_open_file) return(1); sprintf(itm_fname,Itm_template,util_dir(newsgrp.grp_name),newsitm.itm_num); ! return(fopen(itm_fname,"r","mbc=16","mbf=2","rop=rah")); } /* ************** *** 2462,2468 return(write_net(msg[M423],stm)); cxt[stm].curr_item = newsitm.itm_num; sprintf(itm_fname,Itm_template,util_dir(newsgrp.grp_name),newsitm.itm_num); ! if (!(fpr = fopen(itm_fname,"r"))) return(write_net(msg[M430],stm)); } sprintf(sbuf,msg[M220 + cmd_type],newsitm.itm_num,newsitm.itm_id); --- 2476,2482 ----- return(write_net(msg[M423],stm)); cxt[stm].curr_item = newsitm.itm_num; sprintf(itm_fname,Itm_template,util_dir(newsgrp.grp_name),newsitm.itm_num); ! if (!(fpr = fopen(itm_fname,"r","mbc=16"))) return(write_net(msg[M430],stm)); } sprintf(sbuf,msg[M220 + cmd_type],newsitm.itm_num,newsitm.itm_id); ************** *** 2761,2767 FILE *fpr; char inpline[512], *cp1; ! if (fpr = fopen(DISTRIBUTIONS_FILE,"r")) { write_net(msg[M215],stm); while (fgets(inpline,sizeof(inpline),fpr)) { if (cp1 = strchr(inpline,'#')) *cp1 = '\0'; --- 2775,2781 ----- FILE *fpr; char inpline[512], *cp1; ! if (fpr = fopen(DISTRIBUTIONS_FILE,"r","mbc=16")) { write_net(msg[M215],stm); while (fgets(inpline,sizeof(inpline),fpr)) { if (cp1 = strchr(inpline,'#')) *cp1 = '\0'; ************** *** 3091,3097 int stm; { write_net(msg[M205],stm); - #if LEAVE_SPOOL_OPEN if (fpb) { fclose(fpb); fpb = 0; --- 3105,3110 ----- int stm; { write_net(msg[M205],stm); if (fpb) { fclose(fpb); fpb = 0; ************** *** 3096,3102 fclose(fpb); fpb = 0; } - #endif next_call(stm,CLOSE_LINK,NO_INPUT); } --- 3109,3114 ----- fclose(fpb); fpb = 0; } next_call(stm,CLOSE_LINK,NO_INPUT); } ************** *** 3447,3453 if (!isl) { sprintf(itm_fname,Itm_template,util_dir(newsgrp.grp_name),newsitm.itm_num); sprintf(buf,"%d",low); ! if (fp = fopen(itm_fname,"r")) { print_header(fp,argv[1],buf,stm); fclose(fp); } --- 3459,3465 ----- if (!isl) { sprintf(itm_fname,Itm_template,util_dir(newsgrp.grp_name),newsitm.itm_num); sprintf(buf,"%d",low); ! if (fp = fopen(itm_fname,"r","mbc=16")) { print_header(fp,argv[1],buf,stm); fclose(fp); } ************** *** 3763,3769 server_shut() { - #if LEAVE_SPOOL_OPEN if (fpb) { fclose(fpb); fpb = 0; --- 3775,3780 ----- server_shut() { if (fpb) { fclose(fpb); fpb = 0; ************** *** 3768,3774 fclose(fpb); fpb = 0; } - #endif sys$close(&grpfab); sys$close(&itmfab); close_hist_file(); --- 3779,3784 ----- fclose(fpb); fpb = 0; } sys$close(&grpfab); sys$close(&itmfab); close_hist_file(); ************** *** 3829,3835 } c$cks(1); if (!logfile) return; ! if (!(fpl = fopen(logfile,"a"))) { sleep(1); /* maybe someone has the file open */ fpl = fopen(logfile,"a"); } --- 3839,3845 ----- } c$cks(1); if (!logfile) return; ! if (!(fpl = fopen(logfile,"a","alq=32","deq=32","fop=cbt"))) { sleep(1); /* maybe someone has the file open */ fpl = fopen(logfile,"a","alq=32","deq=32","fop=cbt"); } ************** *** 3831,3837 if (!logfile) return; if (!(fpl = fopen(logfile,"a"))) { sleep(1); /* maybe someone has the file open */ ! fpl = fopen(logfile,"a"); } if (fpl) { fprintf(fpl,"%s %s: nntprecv: %s@%s received: %d posted: %d failed: %d rejected: %d read: %d articles, %d newsgroups\n", --- 3841,3847 ----- if (!logfile) return; if (!(fpl = fopen(logfile,"a","alq=32","deq=32","fop=cbt"))) { sleep(1); /* maybe someone has the file open */ ! fpl = fopen(logfile,"a","alq=32","deq=32","fop=cbt"); } if (fpl) { fprintf(fpl,"%s %s: nntprecv: %s@%s received: %d posted: %d failed: %d rejected: %d read: %d articles, %d newsgroups\n", *** newssite.h --- newssite_new.h ************** *** 20,22 /* * EXP_TIME --- 20,24 ----- + /* NNTP version identification */ + #define nntp_version "6.1.1" /* * EXP_TIME ************** *** 27,33 */ #define EXP_TIME 14 ! #define GRP_TIME 60 /* * NEWS_BATCH_SIZE --- 29,35 ----- */ #define EXP_TIME 14 ! #define GRP_TIME -1 /* The following NNTP items were moved from NNTP_SERVER by saul@hnrc.tufts.edu 7/16/93 ************** *** 29,34 #define EXP_TIME 14 #define GRP_TIME 60 /* * NEWS_BATCH_SIZE * This is the maximum size of news batch files (in bytes - not blocks) --- 31,39 ----- #define EXP_TIME 14 #define GRP_TIME -1 + /* The following NNTP items were moved from NNTP_SERVER by saul@hnrc.tufts.edu + 7/16/93 + */ /* * NEWS_BATCH_SIZE * This is the default maximum size of news batch files (in bytes - not blocks) ************** *** 31,37 /* * NEWS_BATCH_SIZE ! * This is the maximum size of news batch files (in bytes - not blocks) */ #define NEWS_BATCH_SIZE 250000 --- 36,44 ----- */ /* * NEWS_BATCH_SIZE ! * This is the default maximum size of news batch files (in bytes - not blocks) ! * May be overriden by setting the NEWS_BATCH_SIZE logical ! * HIGHLIM and LOLIM are bounds around the batch size */ #define NEWS_BATCH_SIZE (1000*512) ************** *** 34,40 * This is the maximum size of news batch files (in bytes - not blocks) */ ! #define NEWS_BATCH_SIZE 250000 /* * RECHECK_TIMER --- 41,49 ----- * HIGHLIM and LOLIM are bounds around the batch size */ ! #define NEWS_BATCH_SIZE (1000*512) ! #define NEWS_BATCH_SIZE_HIGHLIM (10000*512) ! #define NEWS_BATCH_SIZE_LOWLIM (10*512) /* NEWSBATCH * Template for NNTP batch file names,filled in with time and PID ************** *** 36,41 #define NEWS_BATCH_SIZE 250000 /* * RECHECK_TIMER * The configuration files are periodically re-checked to ensure that any edit --- 45,67 ----- #define NEWS_BATCH_SIZE_HIGHLIM (10000*512) #define NEWS_BATCH_SIZE_LOWLIM (10*512) + /* NEWSBATCH + * Template for NNTP batch file names,filled in with time and PID + */ + #define NEWSBATCH "NEWS_MANAGER:NNTP_%s_%X.BATCH" + + /* LOGGING + * set to 1 to produce LOGGING output + * to logical NEWS_NNTP_LOG file + */ + #define LOGGING 1 + + /* ALWAYS_SPOOL + * set to 1 to spool ALL POST items - other spool only Control items + */ + + #define ALWAYS_SPOOL 0 + /* end of NNTP items */ /* * RECHECK_TIMER * The configuration files are periodically re-checked to ensure that any edit *** patchlist.h;-1 --- patchlist.h ************** *** 1,1 =+=+= End =+=+= --- 1,2 ----- + 930723_nntp_server.c!saul@hnrc.tufts.edu =+=+= End =+=+=