INN commit: trunk/innd (art.c innd.h nc.c)

INN Commit Russ_Allbery at isc.org
Sat Feb 10 23:34:14 UTC 2007


    Date: Saturday, February 10, 2007 @ 15:34:14
  Author: eagle
Revision: 7606

Improve rejection logging.  Catch several places where we rejected
articles without incrementing the rejected size count, uniformly use
ARTreject to increment the statistics, and count rejected duplicates
as part of the rejected article size since they're also included in
the count.

Drop the unused third parameter to ARTreject.

Modified:
  trunk/innd/art.c
  trunk/innd/innd.h
  trunk/innd/nc.c

--------+
 art.c  |   50 ++++++++++++++++++++------------------------------
 innd.h |    7 +++++++
 nc.c   |    9 ++++-----
 3 files changed, 31 insertions(+), 35 deletions(-)

Modified: art.c
===================================================================
--- art.c	2007-02-10 22:35:16 UTC (rev 7605)
+++ art.c	2007-02-10 23:34:14 UTC (rev 7606)
@@ -69,12 +69,6 @@
 static char	*ARTpathme;
 
 /*
-**  Different types of rejected articles.
-*/
-typedef enum {REJECT_DUPLICATE, REJECT_SITE, REJECT_FILTER, REJECT_DISTRIB,
-	      REJECT_GROUP, REJECT_UNAPP, REJECT_OTHER} Reject_type;
-
-/*
 **  Flag array, indexed by character.  Character classes for Message-ID's.
 */
 static char		ARTcclass[256];
@@ -1092,11 +1086,13 @@
 **  We are going to reject an article, record the reason and
 **  and the article.
 */
-static void
-ARTreject(Reject_type code, CHANNEL *cp, struct buffer *article UNUSED)
+void
+ARTreject(Reject_type code, CHANNEL *cp)
 {
   /* Remember why the article was rejected (for the status file) */
 
+  cp->Rejected++;
+  cp->RejectSize += cp->Next - cp->Start;
   switch (code) {
     case REJECT_DUPLICATE:
       cp->Duplicate++;
@@ -1104,27 +1100,21 @@
       break;
     case REJECT_SITE:
       cp->Unwanted_s++;
-      cp->RejectSize += cp->Next - cp->Start;
       break;
     case REJECT_FILTER:
       cp->Unwanted_f++;
-      cp->RejectSize += cp->Next - cp->Start;
       break;
     case REJECT_DISTRIB:
       cp->Unwanted_d++;
-      cp->RejectSize += cp->Next - cp->Start;
       break;
     case REJECT_GROUP:
       cp->Unwanted_g++;
-      cp->RejectSize += cp->Next - cp->Start;
       break;
     case REJECT_UNAPP:
       cp->Unwanted_u++;
-      cp->RejectSize += cp->Next - cp->Start;
       break;
     case REJECT_OTHER:
       cp->Unwanted_o++;
-      cp->RejectSize += cp->Next - cp->Start;
       break;
     default:
       /* should never be here */
@@ -1814,14 +1804,14 @@
   if (!artclean && (!HDR_FOUND(HDR__PATH) || !HDR_FOUND(HDR__MESSAGE_ID))) {
     /* cp->Error is set since Path and Message-ID are required header and one
        of two is not found at ARTclean(). */
-    ARTreject(REJECT_OTHER, cp, article);
+    ARTreject(REJECT_OTHER, cp);
     return false;
   }
   hopcount = ARTparsepath(HDR(HDR__PATH), HDR_LEN(HDR__PATH), &data->Path);
   if (hopcount == 0) {
     snprintf(cp->Error, sizeof(cp->Error), "%d illegal path element",
             NNTP_FAIL_IHAVE_REJECT);
-    ARTreject(REJECT_OTHER, cp, article);
+    ARTreject(REJECT_OTHER, cp);
     return false;
   }
   hops = data->Path.List;
@@ -1842,7 +1832,7 @@
   if (HIScheck(History, HDR(HDR__MESSAGE_ID))) {
     snprintf(cp->Error, sizeof(cp->Error), "%d Duplicate", NNTP_FAIL_IHAVE_REJECT);
     ARTlog(data, ART_REJECT, cp->Error);
-    ARTreject(REJECT_DUPLICATE, cp, article);
+    ARTreject(REJECT_DUPLICATE, cp);
     return false;
   }
   if (!artclean) {
@@ -1851,7 +1841,7 @@
 	!InndHisRemember(HDR(HDR__MESSAGE_ID)))
       syslog(L_ERROR, "%s cant write history %s %m", LogName,
 	HDR(HDR__MESSAGE_ID));
-    ARTreject(REJECT_OTHER, cp, article);
+    ARTreject(REJECT_OTHER, cp);
     return false;
   }
 
@@ -1875,7 +1865,7 @@
 	  !InndHisRemember(HDR(HDR__MESSAGE_ID)))
 	syslog(L_ERROR, "%s cant write history %s %m", LogName,
 	  HDR(HDR__MESSAGE_ID));
-      ARTreject(REJECT_SITE, cp, article);
+      ARTreject(REJECT_SITE, cp);
       return false;
     }
   }
@@ -1902,7 +1892,7 @@
 	  !InndHisRemember(HDR(HDR__MESSAGE_ID)))
 	syslog(L_ERROR, "%s cant write history %s %m", LogName,
 	  HDR(HDR__MESSAGE_ID));
-      ARTreject(REJECT_FILTER, cp, article);
+      ARTreject(REJECT_FILTER, cp);
       return false;
     }
   }
@@ -1928,7 +1918,7 @@
 	  !InndHisRemember(HDR(HDR__MESSAGE_ID)))
 	syslog(L_ERROR, "%s cant write history %s %m", LogName,
 	  HDR(HDR__MESSAGE_ID));
-      ARTreject(REJECT_FILTER, cp, article);
+      ARTreject(REJECT_FILTER, cp);
       return false;
     }
   }
@@ -1945,7 +1935,7 @@
 	  !InndHisRemember(HDR(HDR__MESSAGE_ID)))
         syslog(L_ERROR, "%s cant write history %s %m", LogName,
 	  HDR(HDR__MESSAGE_ID));
-      ARTreject(REJECT_DISTRIB, cp, article);
+      ARTreject(REJECT_DISTRIB, cp);
       return false;
     } else {
       ARTparsedist(HDR(HDR__DISTRIBUTION), HDR_LEN(HDR__DISTRIBUTION),
@@ -1961,7 +1951,7 @@
 	    !InndHisRemember(HDR(HDR__MESSAGE_ID)))
 	  syslog(L_ERROR, "%s cant write history %s %m",
 	    LogName, HDR(HDR__MESSAGE_ID));
-	ARTreject(REJECT_DISTRIB, cp, article);
+	ARTreject(REJECT_DISTRIB, cp);
 	return false;
       }
     }
@@ -2087,7 +2077,7 @@
 	  !InndHisRemember(HDR(HDR__MESSAGE_ID)))
 	syslog(L_ERROR, "%s cant write history %s %m", LogName,
 	  HDR(HDR__MESSAGE_ID));
-      ARTreject(REJECT_UNAPP, cp, article);
+      ARTreject(REJECT_UNAPP, cp);
       return false;
     }
 
@@ -2110,7 +2100,7 @@
                "%d Won't accept posts in \"%s\"", NNTP_FAIL_IHAVE_REJECT,
                MaxLength(p, p));
       ARTlog(data, ART_REJECT, cp->Error);
-      ARTreject(REJECT_GROUP, cp, article);
+      ARTreject(REJECT_GROUP, cp);
       return false;
     }
 
@@ -2184,7 +2174,7 @@
 	  !NoHistoryUpdate && !InndHisRemember(HDR(HDR__MESSAGE_ID)))
 	  syslog(L_ERROR, "%s cant write history %s %m",
 	    LogName, HDR(HDR__MESSAGE_ID));
-	ARTreject(REJECT_GROUP, cp, article);
+	ARTreject(REJECT_GROUP, cp);
 	return false;
       } else {
         /* if !GroupMissing, then all the groups the article was posted
@@ -2197,7 +2187,7 @@
 	      !NoHistoryUpdate && !InndHisRemember(HDR(HDR__MESSAGE_ID)))
 	    syslog(L_ERROR, "%s cant write history %s %m",
 	      LogName, HDR(HDR__MESSAGE_ID));
-	  ARTreject(REJECT_GROUP, cp, article);
+	  ARTreject(REJECT_GROUP, cp);
 	  return false;
 	}
       }
@@ -2230,7 +2220,7 @@
                  NNTP_FAIL_IHAVE_REJECT);
       }
       ARTlog(data, ART_REJECT, cp->Error);
-      ARTreject(REJECT_OTHER, cp, article);
+      ARTreject(REJECT_OTHER, cp);
       return false;
     }
   } else {
@@ -2260,7 +2250,7 @@
     if ((Mode == OMrunning) && !InndHisRemember(HDR(HDR__MESSAGE_ID)))
       syslog(L_ERROR, "%s cant write history %s %m", LogName,
 	HDR(HDR__MESSAGE_ID));
-    ARTreject(REJECT_OTHER, cp, article);
+    ARTreject(REJECT_OTHER, cp);
     TMRstop(TMR_ARTWRITE);
     return false;
   }
@@ -2299,7 +2289,7 @@
     snprintf(cp->Error, sizeof(cp->Error), "%d cant write history, %s",
              NNTP_FAIL_IHAVE_DEFER, strerror(errno));
     ARTlog(data, ART_REJECT, cp->Error);
-    ARTreject(REJECT_OTHER, cp, article);
+    ARTreject(REJECT_OTHER, cp);
     return false;
   }
 

Modified: innd.h
===================================================================
--- innd.h	2007-02-10 22:35:16 UTC (rev 7605)
+++ innd.h	2007-02-10 23:34:14 UTC (rev 7606)
@@ -357,6 +357,12 @@
 #define	DEFAULTNGBOXSIZE	64
 
 /*
+**  Different types of rejected articles.
+*/
+typedef enum {REJECT_DUPLICATE, REJECT_SITE, REJECT_FILTER, REJECT_DISTRIB,
+	      REJECT_GROUP, REJECT_UNAPP, REJECT_OTHER} Reject_type;
+
+/*
 **  A newsgroup has a name in different formats, and a high-water count,
 **  also kept in different formats.  It also has a list of sites that
 **  get this group.
@@ -633,6 +639,7 @@
 extern void		ARTsetup(void);
 extern void		ARTprepare(CHANNEL *cp);
 extern void		ARTparse(CHANNEL *cp);
+extern void		ARTreject(Reject_type, CHANNEL *);
 
 extern bool		CHANsleeping(CHANNEL *cp);
 extern CHANNEL      *	CHANcreate(int fd, enum channel_type Type,

Modified: nc.c
===================================================================
--- nc.c	2007-02-10 22:35:16 UTC (rev 7605)
+++ nc.c	2007-02-10 23:34:14 UTC (rev 7606)
@@ -207,7 +207,6 @@
     } else
       response = NNTP_TOOKIT;
   } else {
-    cp->Rejected++;
     if (cp->Sendid.size)
       response = cp->Sendid.data;
     else
@@ -904,8 +903,7 @@
 
       /* If error is set, we're rejecting this article. */
       if (*cp->Error != '\0') {
-	cp->Rejected++;
-	cp->RejectSize += cp->Next - cp->Start;
+	ARTreject(REJECT_OTHER, cp);
 	cp->State = CSgetcmd;
 	cp->Start = cp->Next;
 	NCclearwip(cp);
@@ -931,7 +929,7 @@
 	/* Clear the work-in-progress entry. */
 	NCclearwip(cp);
 	NCwriteshutdown(cp, ModeReason);
-	cp->Rejected++;
+	ARTreject(REJECT_OTHER, cp);
 	return;
       }
 
@@ -1065,7 +1063,7 @@
 	  NCwritereply(cp, NNTP_OK_XBATCHED);
 	  cp->Received++;
 	} else
-	  cp->Rejected++;
+          ARTreject(REJECT_OTHER, cp);
       }
       syslog(L_NOTICE, "%s accepted batch size %d", CHANname(cp),
 	cp->XBatchSize);
@@ -1073,6 +1071,7 @@
       cp->Start = cp->Next = cp->XBatchSize;
       break;
     }
+
     if (cp->State == CSwritegoodbye || cp->Type == CTfree)
       break;
     if (Tracing || cp->Tracing)



More information about the inn-committers mailing list