πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #82614

Re: INN and "ovgrouppat" - bug?

#82614
From: D. Stussy
Date: Mon, 18 Jan 2010 05:02
115 lines
5359 bytes
"Julien Γ‰LIE" <iulius@nom-de-mon-site.com.invalid> wrote in message
news:hiutsh$etq$1@news.trigofacile.com...
> >>> I have just added that precision to the inn.conf documentation for
> >>> ovgrouppat:
> >
> >>> Note that the use of "!" in this wildmat expression has the same
> >>> meaning as "@", that is to say it is a poisoned match and the
overview
> >>> data will not be generated if one of the newsgroups an article is
> >>> posted to is unwanted.
> >
> > Why in this situation do we not use the more typical meaning of "!" and
> > "@" and keep generating overview unless every newsgroup to which it's
> > posted does not match or unless it matches a poisoned pattern?  The
code
> > structure just doesn't allow for it?
>
> Yes, you're right Russ.  I should have fixed the problem instead of
> documenting the difference between usual wildmats.
> Now done.
>
>   http://inn.eyrie.org/trac/changeset/8890/trunk
>
>     Add complete support for uwildmats in ovgrouppat: negated
>     patterns "!" are now taken into account (and not considered
>     as poisoned patterns "@").

In my opinion, the patch could be optimized.  Instead of checking from left
to right (0 to OVnumpatterns-1), we could check from right to left and
return immediately upon the first matching element:

enum uwildmat
OVgroupmatch(const char *group)
{
    int i;

    if (OVnumpatterns == 0 || group == NULL)
        return UWILDMAT_MATCH;
    for (i = OVnumpatterns - 1; i >= 0; --i) {
        switch (OVpatterns[i][0]) {
        case '!':
             if (uwildmat(group, &OVpatterns[i][1])) {
                return UWILDMAT_FAIL;
            }
            break;
       case '@':
            if (uwildmat(group, &OVpatterns[i][1])) {
                return UWILDMAT_POISON;
            }
            break;
        default:
            if (uwildmat(group, OVpatterns[i]))
                return UWILDMAT_MATCH;
        }
    }
    return UWILDMAT_FAIL;
}

However, doesn't that make the whole thing equivalent to:

enum uwildmat OVgroupmatch(const char *group)
{
    return (innconf->ovgrouppat == NULL || group == NULL)
        ? UWILDMAT_MATCH
         : uwildmat_poison(group,innconf->ovgrouppat);
}

i.e. use the existing function (except for the pre-parsing*)?  There may be
further code optimizations@.

* - looking at "match_expression()" in lib/uwildmat.c, I don't see where
the pre-parsing is an advantage.  Each pattern is still going to be scanned
for commas, so splitting it up only saves time if we aren't scanning for
them.

@ - As OVgroupmatch() is called ONLY from one place, OVadd(), from inside a
conditional that checked for innconf->ovgrouppat != NULL, and from inside a
loop that makes certain that group != NULL, the conditional inside the
function optimizes out completely - effectively:

#define OVgroupmatch(x) uwildmat_poison(x,innconf->ovgrouppat)

BTW,  switch may be cleaner than if-elseif.  (Lines 205-215 of storage/ov.c
become):

            switch(uwildmat_poison(group, innconf->ovgrouppat)){
                case UWILDMAT_FAIL:
                    if (!SMprobe(SELFEXPIRE, &token, NULL) &&
innconf->groupbaseexpiry)
                    /* this article will never be expired, since it does
not
                       have self expiry function in stored method and
                       groupbaseexpiry is true */
                        return OVADDFAILED;
                case UWILDMAT_FAIL:
                    return OVADDGROUPNOMATCH;
            }

...And now that we're using an actual wildmat call, there are no
documentation changes.  ;-)

>     Also fix a wrong memchr length.
>
> Yeah, that memchr was strange (group is always greater than patcheck...).
> It could have led to segfaults (especially with the write of '\0' just
after).
>
> -            if ((nextcheck = memchr(group, ':', xreflen - (patcheck -
group))) == NULL)
> +            if ((nextcheck = memchr(group, ':', xreflen - (group -
patcheck))) == NULL)

OK.

Technical Details
Message-ID: <hj0q1j$ggh$1@snarked.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20141118.mbox.gz!border1.nntp.dca.giganews.com!nntp.giganews.com!news-in-01.newsfeed.easynews.com!news-in-02.newsfeed.easynews.com!easynews.com!easynews!news.he.net!news.snarked.org!not-for-mail
References: <hihikq$hje$1@snarked.org> <hiiie2$3ur$1@news.trigofacile.com><hism7f$rn3$1@news.trigofacile.com> <hiu3cd$715$1@snarked.org> <87vdf1ic39.fsf@windlord.stanford.edu> <hiutsh$etq$1@news.trigofacile.com>

Show Full Headers
Complete Article Headers
Message-ID: <hj0q1j$ggh$1@snarked.org>
Subject: Re: INN and "ovgrouppat" - bug?
Date: Sun, 17 Jan 2010 21:02:04 -0800
From: "D. Stussy" <spam+newsgroups@bde-arc.ampr.org>
References: <hihikq$hje$1@snarked.org> <hiiie2$3ur$1@news.trigofacile.com><hism7f$rn3$1@news.trigofacile.com> <hiu3cd$715$1@snarked.org> <87vdf1ic39.fsf@windlord.stanford.edu> <hiutsh$etq$1@news.trigofacile.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.20141118.mbox.gz!border1.nntp.dca.giganews.com!nntp.giganews.com!news-in-01.newsfeed.easynews.com!news-in-02.newsfeed.easynews.com!easynews.com!easynews!news.he.net!news.snarked.org!not-for-mail
Newsgroups: news.software.nntp
Lines: 115
Reply-To: "D. Stussy" <replies@newsgroups.kd6lvw.ampr.org>
NNTP-Posting-Host: pool-71-118-53-20.lsanca.dsl-w.verizon.net
X-Trace: snarked.org 1263790963 16913 71.118.53.20 (18 Jan 2010 05:02:43 GMT)
X-Complaints-To: newsmaster+complaints@snarked.org
NNTP-Posting-Date: Mon, 18 Jan 2010 05:02:43 +0000 (UTC)
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1478
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1478