🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #2614

RN/TRN article number problem

#2614
From: Clifford A Adams
Date: Wed, 02 Dec 1992 07:19
94 lines
4066 bytes
In article <19921130165314SEB1525@MVS.draper.com> SEB1525@MVS.draper.com (Steve Bacher) writes:
>Has anyone given serious thought to the impending crisis that will
>affect all news servers and news readers eventually?
>...

	When I saw this I remembered a more immediate possibility.
The current versions of RN (4.4 pl4) and TRN (2.0 pl2) have this
problem when compiled for a local spool (when SERVER is not #defined).
In short, after 1000000 (1 million) articles, some fairly common
circumstances can cause all articles in the group to be marked as read.
;
Here is the code that causes the problem (from RN 4.4 pl4, file ngdata.c):
(The TRN code is substantially the same.)
-------------------- cut --------------------
/* scan a directory for minimum article number greater than floor */

ART_NUM
getngmin(dirname,floor)
char *dirname;
ART_NUM floor;
{
    register DIR *dirp;
    register struct DIRTYPE *dp;
    register ART_NUM min = 1000000;
    register ART_NUM maybe;
    register char *p;
#ifdef notdef
    char tmpbuf[128];
#endif

    dirp = opendir(dirname);
    if (!dirp)
        return 0;
    while ((dp = readdir(dirp)) != Null(struct DIRTYPE *)) {
        if ((maybe = atol(dp->d_name)) < min && maybe > floor) {
            for (p = dp->d_name; *p; p++)
                if (!isdigit(*p))
                    goto nope;
#ifdef notdef
           /*
            * If newsgroup names ever go entirely numeric, then
            * this code will have to be reinserted.
            * For the time being, we assume that if a numeric name is
            * found, it must be an article (and not a directory).
            * This will avoid two stat(2) calls for those running
            * rn.
            */
            if (*dirname == '.' && !dirname[1])
                stat(dp->d_name, &filestat);
            else {
                sprintf(tmpbuf,"%s/%s",dirname,dp->d_name);
                stat(tmpbuf, &filestat);
            }
            if (! (filestat.st_mode & S_IFDIR))
#endif
                min = maybe;
        }
      nope:
        ;
    }
    closedir(dirp);
    return min==1000000 ? 0 : min;
}
-------------------- cut --------------------

The fix is to change the following lines:
old:
    register ART_NUM min = 1000000;
new:
    register ART_NUM min = 0;

old:
        if ((maybe = atol(dp->d_name)) < min && maybe > floor) {
new:
        if (((maybe = atol(dp->d_name)) < min && maybe > floor) || min==0) {

old:
    return min==1000000 ? 0 : min;
new:
    return min;

	After this fix article numbers can go up to the full range of
ART_NUM (usually a long).  Luckily I found out about this code the
easy way, but I could imagine someone running into the 1-million
limit.  (Around here the highest group article numbers are around 150000.)

				--Cliff
-- 
Clifford A. Adams --- "Understanding is inasmuch as becoming."
caadams@triton.unm.edu | 457 Ash St. NE/Albuquerque, NM 87106 | (505) 242-4519
Programmer in the USENET Moderation Project: tools for advanced filtering
(many-moderator groups, keyword/summary addition, prioritizing newsreaders...)

Technical Details
Message-ID: <!31qvld@lynx.unm.edu>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.admin.technical.mbox.zip!sparky!uunet!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!ames!pacbell.com!tandem!zorch!scott
References: <19921130165314SEB1525@MVS.draper.com>

Show Full Headers
Complete Article Headers
Message-ID: <!31qvld@lynx.unm.edu>
Subject: RN/TRN article number problem
Date: Wed, 2 Dec 1992 07:19:47 GMT
From: caadams@polaris.unm.edu (Clifford A Adams)
References: <19921130165314SEB1525@MVS.draper.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.admin.technical.mbox.zip!sparky!uunet!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!ames!pacbell.com!tandem!zorch!scott
Newsgroups: news.misc,news.software.readers,news.admin.technical
Summary: Above 1,000,000 articles both programs get kill-happy.
Keywords: rn, trn, source, bug, fix
Sender: scott@zorch.SF-Bay.ORG (Scott Hazen Mueller)
Organization: University of New Mexico
Approved: scott@zorch.SF-Bay.ORG
Lines: 93