ANU News Patch Patch ID: 940604_newsdist.c!munroe@dmc.com Date: 04-Jun-1994 Author: Dick Munroe munroe@dmc.com News Version: 6.1beta9 News Files: NewsDist.C, NewsDefine.H, NewsSite.H Description: Allows site to specify size limit for type N spool file in News.Sys entry, using the format N###, where ### is the approximate maximum number of message-IDs to place in a given spool file. *** newsdist.c --- newsdist_new.c ************** *** 71,73 **-- **/ --- 71,77 ----- + ** V6.1b9 04-Jun-1994 munroe@dmc.com + ** - Rig a mechanism for limiting the sizes of individual NNTP batches. + ** The Type of Batch field can be of the form Nnumber where number is + ** the number of articles to be included in each batch. **-- **/ ************** *** 255,261 if (!type || !*type || *type == 'm') return(size); if (*type == 'b') ++type; ! if (*type == 'n') ++type; if (isdigit(*type)) size = atoi(type); return(size); } --- 259,268 ----- if (!type || !*type || *type == 'm') return(size); if (*type == 'b') ++type; ! if (*type == 'n') { ! ++type; ! size = NEWS_NNTP_BATCH_SIZE; ! } if (isdigit(*type)) size = atoi(type); return(size); } ************** *** 410,416 } tmp->sys_enext = 0; /* wcf 7/22/92 */ ! tmp->sys_article_count = tmp->sys_article_bytes = tmp->sys_id_count = 0; if (!sysfile) sysfile = tmp; else { while (t1->sys_enext) t1 = t1->sys_enext; --- 417,423 ----- } tmp->sys_enext = 0; /* wcf 7/22/92 */ ! tmp->sys_article_count = tmp->sys_article_bytes = tmp->sys_id_count = tmp->sys_estimated_article_count = 0; if (!sysfile) sysfile = tmp; else { while (t1->sys_enext) t1 = t1->sys_enext; ************** *** 938,943 if (!(fpo = fopen(s->sys_file,"a","shr=nil","mbc=64"))) fpo = fopen(s->sys_file,"w","shr=nil","mbc=64"); } #if !CLOSE_BATCHFILES s->sys_fp = fpo; #endif --- 945,977 ----- if (!(fpo = fopen(s->sys_file,"a","shr=nil","mbc=64"))) fpo = fopen(s->sys_file,"w","shr=nil","mbc=64"); } + else { + /* + ** Assume that each entry in the collection file is about 40 bytes + ** long. From inspection this seems to be about the right number. + ** Only do this calculation once, when the file is opened. After + ** that it's redundant. + */ + + fstat(fileno(fpo), &s->sys_statb); + s->sys_estimated_article_count = (s->sys_statb.st_size + 39) / 40 ; + } + #if !CLOSE_BATCHFILES + s->sys_fp = fpo; + #endif + } + if (((s->sys_id_count + s->sys_estimated_article_count) % s->sys_batch_size) == 0) { + /* + ** By our calculations, the number of articles in the current batch + ** file has overflowed the number specified in the news.sys file + ** entry. Close the current batch, open a new one and adjust the + ** estimated article count so that we will write the correct number + ** of news items into the next batch. + */ + + fclose(fpo) ; + fpo = fopen(s->sys_file,"w","shr=nil","mbc=64"); + s->sys_estimated_article_count = - s->sys_id_count ; #if !CLOSE_BATCHFILES s->sys_fp = fpo; #endif *** newsdefine.h --- newsdefine_new.h ************** *** 22,24 **-- **/ --- 22,26 ----- + ** 6.1b9 4-Jun-1994 Dick Munroe munroe@dmc.com + ** - added estimated article count. **-- **/ ************** *** 551,556 char *sys_type; char *sys_file; int sys_batch_size; int sys_article_count; int sys_article_bytes; int sys_id_count; /* IHAVE ID's */ --- 553,559 ----- char *sys_type; char *sys_file; int sys_batch_size; + int sys_estimated_article_count ; int sys_article_count; int sys_article_bytes; int sys_id_count; /* IHAVE ID's */ *** newssite.h --- newssite_new.h ************** *** 37,42 #define NEWS_BATCH_SIZE 250000 /* * RECHECK_TIMER * The configuration files are periodically re-checked to ensure that any edit * changes made to the files are read into all active NEWS sessions. The timer --- 37,50 ----- #define NEWS_BATCH_SIZE 250000 /* + * NEWS_NNTP_BATCH_SIZE + * This is the maximum size of news batchs files for NNTP sites (in + * articles, not bytes). + */ + + #define NEWS_NNTP_BATCH_SIZE 250 + + /* * RECHECK_TIMER * The configuration files are periodically re-checked to ensure that any edit * changes made to the files are read into all active NEWS sessions. The timer *** patchlist.h;-1 --- patchlist.h ************** *** 1,1 =+=+= End =+=+= --- 1,2 ----- + 940604_newsdist.c!munroe@dmc.com =+=+= End =+=+=