Hi, inn-workers! I want two features. 1) Show spool size for peer, like: ttyri://vinny@zeus:~> finger dg:OUTBOUND@news2.lucky.net [news2.lucky.net] =============================================================================== Queue file Articles size Articles Queue file date ------------------------------------------------------------------------------- dg-2.input 29.28G 85989 Thu Jul 8 18:09:18 2004 dg-2.output 659.6M 3212 Thu Jul 8 15:49:11 2004 dg.input 597.3M 40363 Thu Jul 8 18:09:18 2004 dg.output 10.76M 1022 Thu Jul 8 16:16:51 2004 ------------------------------------------------------------------------------- TOTAL: 30.55G 130586 NOW: Thu Jul 8 18:09:18 2004 ttyri://vinny@zeus:~> 2) Cutoff articles obtained from tape (backlog file) at local news system, if age of the article is more then value of parameter "artcutoff" set at remote news system. Daily Usenet report for this features looks like: Cut off articles from backlog: Server Spooled UnSpooled CutOff %UnSpooled %CutOff %ReQueued dg 1983 1983 0 100% 0% 100% dg-2 102461 80476 40282 78% 50% 39% horse 5345 5345 4 100% 0% 99% horse2 46660 67472 11009 144% 16% 121% sovam 3660 3660 0 100% 0% 100% sovam-2 30435 20470 16216 67% 79% 13% TOTAL: 6 190544 179406 67511 94% 37% 64% Backlog files shrunk by innfeed: Server Size dg-2 5.7 MB TOTAL: 1 5.7 MB ------------------------------------------------------------------------------- For this purposes I need size and post time of the article in tape (backlog file), and in internal data structure "struct article_s". This patch gets size and posts time of the article from INN, and inserts it to struct article_s and backlog file if innfeed funnel master is set up like this: innfeed!:!*:Tc,Wnmbp*:/usr/local/news/bin/startinnfeed If innfeed funnel master is set up in the old way then nothing will change in its behaviour. -- Good Luck! Sergey Babitch (SB551-RIPE) ICQ: 105517491 FreeLance Artist -- Attached file included as plaintext by Ecartis -- # # Add size and post time of the article to tape (backlog file). # --- inn-2.4.1/innfeed/article.c Thu Jan 8 00:47:19 2004 +++ work/innfeed/article.c Wed Jul 7 11:11:35 2004 @@ -52,6 +52,8 @@ int refCount ; /* the reference count on this article */ char *fname ; /* the file name of the article */ char *msgid ; /* the msgid of the article (INN tells us) */ + int size ; /* the size of the article (INN tells us) */ + time_t post ; /* the article post time (INN tells us) */ Buffer contents ; /* the buffer of the actual on disk stuff */ Buffer *nntpBuffers ; /* list of buffers for transmisson */ const void *mMapping ; /* base of memory mapping, or NULL if none */ @@ -181,7 +183,10 @@ /* Create a new article object. First looks to see if one with the given message id already exists in the hash table and if so returns that (after incrementing the reference count). */ -Article newArticle (const char *filename, const char *msgid) +Article newArticle (const char *filename, + const char *msgid, + int size, + time_t post) { Article newArt = NULL ; @@ -210,7 +215,9 @@ newArt->fname = xstrdup (filename) ; newArt->msgid = xstrdup (msgid) ; - + newArt->size = size ; + newArt->post = post ; + newArt->contents = NULL ; newArt->mMapping = NULL ; newArt->refCount = 1 ; @@ -412,10 +419,15 @@ int artSize (Article article) { if (article == NULL || article->contents == NULL) - return (int)0 ; + return article->size ; return (int)bufferDataSize(article->contents); } + /* return article post time */ +time_t artPostTime (Article article) +{ + return article->post ; +} /* return how many NNTP-ready buffers the article contains */ unsigned int artNntpBufferCount (Article article) --- inn-2.4.1/innfeed/article.h Thu Jan 8 00:47:19 2004 +++ work/innfeed/article.h Thu Jul 1 12:59:12 2004 @@ -25,10 +25,14 @@ #include "misc.h" - - /* Create a new Article object. FILENAME is the path of the file the */ - /* article is in. MSGID is the news message id of the article */ -Article newArticle (const char *filename, const char *msgid) ; + /* Create a new Article object. FILENAME is the path of the file the */ + /* article is in. MSGID is the news message id of the article. SIZE is */ + /* the size of the article got from the INN. POST is the article post */ + /* time (a seconds since epoch, got from the INN). */ +Article newArticle (const char *filename, + const char *msgid, + int size, + time_t post) ; /* delete the given article. Just decrements refcount and then FREEs if the refcount is 0. */ @@ -57,11 +61,14 @@ value can (must) be given to freeBufferArray */ Buffer *artGetNntpBuffers (Article article) ; - /* return the message id stoed in the article object */ + /* return the message id stored in the article object */ const char *artMsgId (Article article) ; /* return size of the article */ int artSize (Article article) ; + + /* return article post time */ +time_t artPostTime (Article article) ; /* return the number of buffers that artGetNntpBuffers() would return. */ unsigned int artNntpBufferCount (Article article) ; --- inn-2.4.1/innfeed/innlistener.c Thu Jan 8 00:47:19 2004 +++ work/innfeed/innlistener.c Wed Jul 7 15:57:54 2004 @@ -370,6 +370,10 @@ InnListener lis = (InnListener) data ; char *msgid, *msgidEnd ; char *fileName, *fileNameEnd ; + char *artSize, *artSizeEnd ; + int size ; + char *postTime, *postTimeEnd ; + time_t post ; char *peer, *peerEnd ; char *cmd, *endc ; char *bbase = bufferBase (buffs [0]) ; @@ -475,7 +479,8 @@ d_printf (2,"INN Command: %s\n", cmd) ; /* pick out the leading string (the filename) */ - if ((fileName = findNonBlankString (cmd,&fileNameEnd)) == NULL) + fileName = findNonBlankString (cmd,&fileNameEnd) ; + if (fileName == NULL) { warn ("ME source format bad, exiting: %s", cmd) ; shutDown (lis) ; @@ -486,7 +491,8 @@ *fileNameEnd = '\0' ; /* for the benefit of newArticle() */ /* now pick out the next string (the message id) */ - if ((msgid = findNonBlankString (fileNameEnd + 1,&msgidEnd)) == NULL) + msgid = findNonBlankString (fileNameEnd + 1,&msgidEnd) ; + if (msgid == NULL) { *fileNameEnd = ' ' ; /* to make syslog work properly */ warn ("ME source format bad, exiting: %s", cmd) ; @@ -497,27 +503,65 @@ *msgidEnd = '\0' ; /* for the benefit of newArticle() */ + /* now pick out the next string (the message size) */ + artSize = findNonBlankString (msgidEnd + 1,&artSizeEnd) ; + if ((artSize ) == NULL) + { + *fileNameEnd = ' ' ; /* to make syslog work properly */ + *msgidEnd = ' ' ; + warn ("ME source format bad, exiting: %s", cmd) ; + shutDown (lis) ; + + return ; + } + *artSizeEnd = '\0' ; + size = strtoul (artSize, &s, 10) ; + if (*s != '\0') + size = 0 ; + *artSizeEnd = ' ' ; + if (size == 0) + artSizeEnd = msgidEnd ; + + /* now pick out the next string (the message post time) */ + postTime = findNonBlankString (artSizeEnd + 1,&postTimeEnd) ; + if (postTime == NULL) + { + *fileNameEnd = ' ' ; /* to make syslog work properly */ + *msgidEnd = ' ' ; + warn ("ME source format bad, exiting: %s", cmd) ; + shutDown (lis) ; + + return ; + } + *postTimeEnd = '\0' ; + post = strtoul (postTime, &s, 10) ; + if (*s != '\0') + post = 0 ; + *postTimeEnd = ' ' ; + if (post == 0) + postTimeEnd = artSizeEnd ; + /* now create an article object and give it all the peers on the rest of the command line. Will return null if file is missing. */ - article = newArticle (fileName, msgid) ; + article = newArticle (fileName, msgid, size, post) ; *fileNameEnd = ' ' ; /* Check the message ID length */ if (strlen(msgid) > NNTP_MSGID_MAXLEN) { warn ("ME message id exceeds limit of %d octets: %s", NNTP_MSGID_MAXLEN, msgid) ; - *(msgidEnd+1) = '\0' ; + *(postTimeEnd+1) = '\0' ; } *msgidEnd = ' ' ; /* Check if message ID starts with < and ends with > */ if (*msgid != '<' || *(msgidEnd-1) != '>') { warn ("ME source format bad, exiting: %s", cmd) ; - *(msgidEnd+1) = '\0'; + *(postTimeEnd+1) = '\0' ; } /* now get all the peernames off the rest of the command lines */ - peerEnd = msgidEnd ; + peerEnd = postTimeEnd ; do { *peerEnd = ' ' ; @@ -765,6 +809,9 @@ static void dropArticle (const char *peerName, Article article) { + int size ; + time_t post ; + static bool logged = false ; if (!logged) @@ -774,8 +821,14 @@ } droppedCount++ ; - fprintf (droppedFp,"%s %s %s\n",artFileName (article), - artMsgId (article), peerName) ; + fprintf (droppedFp,"%s %s",artFileName (article),artMsgId (article)) ; + if ((size = artSize (article)) != 0) + { + fprintf (droppedFp," %d", size) ; + if ((post = artPostTime (article)) != 0) + fprintf (droppedFp," %ld", (long)post) ; + } + fprintf (droppedFp," %s\n", peerName) ; } --- inn-2.4.1/innfeed/tape.c Thu Jan 8 00:47:19 2004 +++ work/innfeed/tape.c Wed Jul 7 16:23:09 2004 @@ -639,8 +639,10 @@ #if 0 QueueElem elem ; #endif - int amt ; + int amt, size, len ; const char *fname, *msgid ; + time_t post ; + char buff [4096] ; ASSERT (tape != NULL) ; @@ -653,7 +655,31 @@ fname = artFileName (article) ; msgid = artMsgId (article) ; - amt = fprintf (tape->outFp,"%s %s\n", fname, msgid) ; + size = artSize (article) ; + post = artPostTime (article) ; + amt = snprintf (buff, sizeof (buff), "%s %s", fname, msgid) ; + if (size != 0) + { + len = strlen (buff) ; + amt += snprintf (buff + len, sizeof (buff) - len, " %d", size) ; + if (post != 0) + { + len = strlen (buff) ; + amt += snprintf (buff+len,sizeof(buff)-len," %ld",(long)post) ; + } + } + len = strlen (buff) ; + amt += snprintf (buff + len, sizeof (buff) - len, "\n") ; + + /* return immediately if buffer overflow (if happen ;) */ + if (amt != strlen (buff)) + { + warn ("ME buffer overflow, skip article: %s %s", fname, msgid) ; + delArticle (article) ; + return; + } + + amt = fprintf (tape->outFp, "%s", buff); /* I'd rather know where I am each time, and I don't trust all fprintf's to give me character counts. */ @@ -668,7 +694,7 @@ #else - tape->outputSize += strlen(fname) + strlen(msgid) + 2 ; /* " " + "\n" */ + tape->outputSize += strlen(buff) ; #endif #endif @@ -702,11 +728,14 @@ are no more articles. */ Article getArticle (Tape tape) { - char line [2048] ; /* ick. 1024 for filename + 1024 for msgid */ + char line [4096] ; /* ick. 1024 for filename + 1024 for msgid + and 2048 for other ;) */ char *p, *q ; char *msgid, *filename ; Article art = NULL ; time_t now = theTime() ; + time_t post ; + int size ; ASSERT (tape != NULL) ; @@ -740,6 +769,7 @@ else { msgid = filename = NULL ; + size = post = 0 ; for (p = line ; *p && CTYPE(isspace, *p) ; p++) /* eat whitespace */ /* nada */ ; @@ -763,7 +793,30 @@ *p = '\0' ; if (p != NULL) - msgid = q ; + { + msgid = q ; + for (p++ ; *p && CTYPE(isspace, *p) ; p++) ; + q = strpbrk (p, " \n") ; + if (q != NULL) + { + *q = '\0' ; + size = strtoul (p, &p, 10) ; + if (*p != '\0') + size = 0 ; + } + if (size != 0) + { + for (q++ ; *q && CTYPE(isspace, *q) ; q++) ; + p = strpbrk (q, " \n") ; + if (p != NULL) + { + *p = '\0' ; + post = strtoul (q, &q, 10) ; + if (*q != '\0') + post = 0 ; + } + } + } else filename = NULL ; /* no trailing newline or blank */ } @@ -787,7 +840,9 @@ } if (filename != NULL && msgid != NULL) - art = newArticle (filename, msgid) ; + { + art = newArticle (filename, msgid, size, post) ; + } /* art may be NULL here if the file is no longer valid. */ } --- inn-2.4.1/samples/newsfeeds.in Thu Jan 8 00:47:19 2004 +++ work/samples/newsfeeds.in Wed Jul 7 16:27:39 2004 @@ -66,7 +66,7 @@ # innfeed funnel master. #innfeed!\ # :!*\ -# :Tc,Wnm*:@prefix@/bin/startinnfeed +# :Tc,Wnmbp*:@prefix@/bin/startinnfeed ## Only uncomment this feed if both enableoverview and useoverchan are ## set to true in inn.conf. By default, innd will write out overview