Article View: news.software.nntp
Article #11338Re: What's wrong with sucking? and how do we fix it?
From: Joe Greco
Date: Wed, 02 Oct 1996 00:00
Date: Wed, 02 Oct 1996 00:00
123 lines
4310 bytes
4310 bytes
In news.software.nntp article <52u0o9$6ur@dfw-ixnews1.ix.netcom.com>, bugs@freebsd.netcom.com (Mark Hittinger) wrote:
:At Netcom I've made adjustments to nnrpd to allow suck feeds to run, however,
:they are now completely unable to overwhelm the server. Once detected they
:are run at a lower priority than the other users.
Sounds like my "oinker" patch.
Let me point out that "suck" feeds are not the only culprit. Running
things like "aub" (Assemble Usenet Binaries), Emacs/GNUS, UQWK, various
NNTP "searching" programs, etc., all often shoot requests at the server
as fast as possible.
So.. a patch was devised.
This is not necessarily portable due to the use of "usleep"... and it
hard codes "(ARTcount > (NowTime - STATstart) * 2)" as the policy to
trip piggy mode... but this is conceptually sufficient to handle this
sort of thing. Tune the parameters for your own site.
Basic idea: If we have asked for more articles than two per second on
average, something is probably "wrong". Start sleeping half a second
after each NNTP command and log them as a piggy.
I do not mind others using this code or a modification of it, but would
appreciate it if it would be attributed to the little piggies over at
Exec-PC Internet. ;-)
*** nnrpd/nnrpd.c.after Tue Jun 25 09:26:55 1996
--- nnrpd/nnrpd.c Tue Jun 25 09:57:37 1996
***************
*** 35,40 ****
--- 35,41 ----
/* Default permission -- change with adb. */
BOOL PERMdefault = FALSE;
+ STATIC int oinker;
STATIC double STATstart;
STATIC double STATfinish;
#if !defined(HPUX)
***************
*** 527,532 ****
--- 528,535 ----
register int i;
char *Reject;
char accesslist[BIG_BUFFER];
+ double NowTime;
+ char TITLEbuf[1024];
#if !defined(HPUX)
/* Save start and extent of argv for TITLEset. */
***************
*** 565,570 ****
--- 568,574 ----
exit(1);
}
STATstart = TIMEINFOasDOUBLE(Now);
+ oinker = 0;
if ((MyHostName = GetConfigValue(_CONF_PATHHOST)) == NULL) {
syslog(L_FATAL, "cant getconfigvalue %m");
***************
*** 616,627 ****
}
! Reply("%d %s InterNetNews NNRP EXP-SA+KA server %s ready (%s).\r\n",
PERMcanpost ? NNTP_POSTOK_VAL : NNTP_NOPOSTOK_VAL,
MyHostName, INNVersion(),
PERMcanpost ? "posting ok" : "no posting");
/* Main dispatch loop. */
for (av = NULL; ; ) {
(void)fflush(stdout);
if (ChangeTrace) {
Tracing = Tracing ? FALSE : TRUE;
--- 620,644 ----
}
! Reply("%d %s InterNetNews NNRP EXP-SA+KA+LL server %s ready (%s).\r\n",
PERMcanpost ? NNTP_POSTOK_VAL : NNTP_NOPOSTOK_VAL,
MyHostName, INNVersion(),
PERMcanpost ? "posting ok" : "no posting");
/* Main dispatch loop. */
for (av = NULL; ; ) {
+ if (oinker) {
+ usleep(500);
+ } else {
+ if (GetTimeInfo(&Now) < 0) {
+ syslog(L_FATAL, "cant gettimeinfo %m");
+ exit(1);
+ }
+ NowTime = TIMEINFOasDOUBLE(Now);
+ if (ARTcount > (NowTime - STATstart) * 2) {
+ oinker++;
+ syslog(L_ERROR, "%s oinker detected", ClientHost);
+ }
+ }
(void)fflush(stdout);
if (ChangeTrace) {
Tracing = Tracing ? FALSE : TRUE;
***************
*** 688,694 ****
NNTP_AUTH_NEEDED_VAL);
continue;
}
! TITLEset(av[0]);
(*cp->Function)(ac, av);
}
--- 705,712 ----
NNTP_AUTH_NEEDED_VAL);
continue;
}
! sprintf(TITLEbuf, "%s%s", oinker ? "OINKER " : "", av[0]);
! TITLEset(TITLEbuf);
(*cp->Function)(ac, av);
}
... JG
Technical Details
Message-ID:
<52uhd2$5ov@brasil.moneng.mei.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mailReferences:
<52stuk$8v@pixi.com> <52u0o9$6ur@dfw-ixnews1.ix.netcom.com>Show Full Headers
Complete Article Headers
Message-ID: <52uhd2$5ov@brasil.moneng.mei.com> Subject: Re: What's wrong with sucking? and how do we fix it? Date: Wed, 02 Oct 1996 00:00:00 +0000 From: jgreco@brasil.moneng.mei.com (Joe Greco) References: <52stuk$8v@pixi.com> <52u0o9$6ur@dfw-ixnews1.ix.netcom.com> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail X-Deja-AN: 186756166 Distribution: inet Organization: Marquette Electronics, Inc. - Milwaukee, WI. Newsgroups: news.software.nntp