Art size logging
Russ Allbery
rra at stanford.edu
Sat Feb 10 23:33:02 UTC 2007
F Senault <fred.letter at lacave.net> writes:
> While I'm trying to obtain interesting stats from my server, I found
> another interesting tidbit : it looks like INN is now logging
> differently duplicate and rejected counts. But there's a little
> inconsistency [1] :
>> seconds 1 accepted 0 refused 47 rejected 3 duplicate 3
>> accepted size 0 duplicate size 3057 rejected size 0
>> seconds 4 accepted 0 refused 104 rejected 17 duplicate 17
>> accepted size 0 duplicate size 18455 rejected size 0
> As you can see, the rejected count includes the duplicated count, but
> the sizes are computed separately, which is, IMHO, confusing.
Yeah, I agree with that. Looking at this code, we also fail to record the
size of articles rejected due to a server throttle and the size of
rejected XBATCH messages.
The root underlying problem behind both your accounting problem and the
other troubles I found is that we don't use a single function to record
statistics about rejections. ARTreject in innd/art.c already handles this
for everything we get as far as NCpost with, and the right solution is to
make it an exported function and use it all the time. Then some minor
rearrangement will take care of this.
While I'm at it, I also dropped the completely unused third argument to
ARTreject.
A diff is appended, for the curious.
> By the way, I was also testing another patch in the stats reporting
> area, which I posted some time ago on nsn newsgroup :
> http://news.lacave.net/inn/status.diff
> It's been tested, and works as advertised. Any thoughts on it ?
news.lacave.net appears to be down. Is there another source for the diff?
Index: innd/nc.c
===================================================================
--- innd/nc.c (revision 7594)
+++ innd/nc.c (working copy)
@@ -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)
Index: innd/art.c
===================================================================
--- innd/art.c (revision 7594)
+++ innd/art.c (working copy)
@@ -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;
}
Index: innd/innd.h
===================================================================
--- innd/innd.h (revision 7585)
+++ innd/innd.h (working copy)
@@ -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,
--
Russ Allbery (rra at stanford.edu) <http://www.eyrie.org/~eagle/>
Please send questions to the list rather than mailing me directly.
<http://www.eyrie.org/~eagle/faqs/questions.html> explains why.
More information about the inn-workers
mailing list