🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.nntp
57 messages
57 total messages Page 1 of 2 Started by Brad Knowles Fri, 01 Oct 1999 00:00
Page 1 of 2 • 57 total messages
Diablo debugging problems...
#40356
Author: Brad Knowles
Date: Fri, 01 Oct 1999 00:00
127 lines
5045 bytes
Folks,

    I'm trying to use the Diablo "pipe" patch that Lars mentioned a couple
of days ago, and I'm having some problems.  Specifically, filtering is
occasionally dying unexpectedly.  I get error messages such as this in
news.err:

Oct  1 14:29:22 <news.err> seymour diablo[1268]: filter write failure:
wanted to write 450523, wrote 393216: Undefined error: 0
Oct  1 14:29:22 <news.err> seymour diablo[1268]: diab-filter: filter
failed, write, sleeping for 4 seconds 
Oct  1 14:29:22 <news.err> seymour diablo[1268]: filter exited on signal 91
Oct  1 14:33:02 <news.err> seymour diablo[1268]: filter write failure:
wanted to write 497437, wrote 393216: Undefined error: 0
Oct  1 14:33:02 <news.err> seymour diablo[1268]: diab-filter: filter
failed, write, sleeping for 9 seconds 
Oct  1 14:33:02 <news.err> seymour diablo[1268]: filter exited on signal 29
Oct  1 14:53:59 <news.err> seymour diablo[1268]: filter write failure:
wanted to write 1004816, wrote 786432: Undefined error: 0
Oct  1 14:53:59 <news.err> seymour diablo[1268]: diab-filter: filter
failed, write, sleeping for 4 seconds 
Oct  1 14:53:59 <news.err> seymour diablo[1268]: filter exited on signal 16

    Now, I decided I'd take a look at what's going on with the daemon
using truss, and relative to these errors, I see the following:

syscall open("/news/spool/news/D.00eebe84/B.6c8b",0,00)
        returns 6 (0x6)
syscall lseek(6,0x449d7,0)
        returns 281047 (0x449d7)
syscall read(0x6,0x8138000,0x6c3e5)
        returns 443365 (0x6c3e5)
SIGNAL 20
SIGNAL 20
SIGNAL 20
syscall write(164,0x8238000,450523)
        returns 393216 (0x60000)
syscall wait4(0xffffffff,0x0,0x1,0x0)
        returns 1747 (0x6d3)
syscall wait4(0xffffffff,0x0,0x1,0x0)
        returns 0 (0x0)
syscall sigreturn(0xbfbfd92c)
        returns 393216 (0x60000)
syscall gettimeofday(0xbfbfcd04,0x0)
        returns 0 (0x0)
syscall getpid()
        returns 1268 (0x4f4)
syscall sendto(0x3,0xbfbfd164,0x70,0x0,0x0,0x0)
        returns 112 (0x70)

    [ ... deletia ... ]

syscall open("/news/spool/news/D.00eebe8e/B.2892",0,00)
        returns 6 (0x6)
syscall lseek(6,0x29858,0)
        returns 170072 (0x29858)
syscall read(0x6,0x8138000,0x77e1e)
        returns 491038 (0x77e1e)
SIGNAL 20
SIGNAL 20
SIGNAL 20
syscall write(164,0x8238000,497437)
        returns 393216 (0x60000)
syscall wait4(0xffffffff,0x0,0x1,0x0)
        returns 1793 (0x701)
syscall wait4(0xffffffff,0x0,0x1,0x0)
        returns 0 (0x0)
syscall sigreturn(0xbfbfd92c)
        returns 393216 (0x60000)
syscall gettimeofday(0xbfbfcd04,0x0)
        returns 0 (0x0)
syscall getpid()
        returns 1268 (0x4f4)
syscall sendto(0x3,0xbfbfd164,0x70,0x0,0x0,0x0)
        returns 112 (0x70)

    [ ... deletia ... ]

syscall open("/news/spool/news/D.00eebea2/B.2892",0,00)
        returns 6 (0x6)
syscall lseek(6,0x2d4f7a,0)
        returns 2969466 (0x2d4f7a)
syscall read(0x6,0x8138000,0xf16b3)
        returns 988851 (0xf16b3)
SIGNAL 20
SIGNAL 20
SIGNAL 20
syscall write(174,0x8238000,1004816)
        returns 786432 (0xc0000)
syscall wait4(0xffffffff,0x0,0x1,0x0)
        returns 2439 (0x987)
syscall wait4(0xffffffff,0x0,0x1,0x0)
        returns 2420 (0x974)
syscall wait4(0xffffffff,0x0,0x1,0x0)
        returns 1366 (0x556)
syscall wait4(0xffffffff,0x0,0x1,0x0)
        returns 1358 (0x54e)
syscall wait4(0xffffffff,0x0,0x1,0x0)
        returns 1357 (0x54d)
syscall wait4(0xffffffff,0x0,0x1,0x0)
        returns 0 (0x0)
syscall sigreturn(0xbfbfd92c)
        returns 786432 (0xc0000)
syscall gettimeofday(0xbfbfcd04,0x0)
        returns 0 (0x0)
syscall getpid()
        returns 1268 (0x4f4)
syscall sendto(0x3,0xbfbfd164,0x71,0x0,0x0,0x0)
        returns 113 (0x71)



    Unfortunately, I'm totally at a loss to figure out what's going
wrong.  The patch doesn't touch filter/diab-filter.c, nor does it touch
anything else in filter/.

    Anyone have any ideas of what I should do next to try and debug this
problem?

-- 
Brad Knowles <brad@shub-internet.org> <http://www.shub-internet.org/brad/>

Are you a USENET news server administrator outside of North America or
Western Europe?  Would you like a newsfeed from a site in the Freenix
Top 100?  If so, please contact me via private e-mail for details.

Re: Diablo debugging problems...
#40328
Author: Brad Knowles
Date: Fri, 01 Oct 1999 00:00
51 lines
2825 bytes
In article <37f4e0b3$0$10188@news.execpc.com>, jgreco@ns.sol.net (Joe
Greco) wrote:

> Well, is your filter process _actually_ exiting, or not?  If so, what's 
> causing it to do so? (*)

    Blargh.  Dunno.  I wasn't bright enough to think of looking for that.

    Hell, I had switched back to the "working" version I had of Diablo
when I realized that I should have thrown truss at the problem, so I had
to switch back to the pipe version, fire up truss on the daemon writing
output to a file, wait for some breakage, and then take a look at the
output of truss.

    I ain't too bright sometimes.  ;-)


    Heck, maybe this is what makes me good at benchmarking things (such as
vinum), because I know this fact and I try to make extra certain that I
cover each and every possible combination.

> It could probably be fixed by wrapping write with a function that
> requires all bytes to be written, although typically I don't recall
> pipes having this sort of behaviour.
> 
> Try changing the write calls to "xwrite", and insert this at the top
> of diab-filter.c.

    Running with this code now.  I've also got the filter process reniced
to +20, so that if I can exercise the same bug with this patch, I should
hopefully do so as quickly as possible.

> If that works, I'll be irritated.

    I won't make any proclamations so far, but I'll let you know.

> And since this snippet is written off the top of my head, it'll be wrong
> and I'll have posted the embarrassing evidence of my incompetence as a C
> programmer.  :-)  So I'll be irritated twice.

    Well, it at least compiled and appears to be running.  I can't yet say
anything else for the resulting code, however.  ;-)

-- 
Brad Knowles <brad@shub-internet.org> <http://www.shub-internet.org/brad/>

Are you a USENET news server administrator outside of North America or
Western Europe?  Would you like a newsfeed from a site in the Freenix
Top 100?  If so, please contact me via private e-mail for details.

Re: Diablo debugging problems...
#40345
Author: Brad Knowles
Date: Fri, 01 Oct 1999 00:00
21 lines
1500 bytes
In article <37f4e0b3$0$10188@news.execpc.com>, jgreco@ns.sol.net (Joe
Greco) wrote:

> If that works, I'll be irritated.

    Well, I've been running that code now for over an hour, and I haven't
had a single error like the ones I had previously reported.  I'm going to
re-nice the filter back up to where it should be and let things run over
the weekend to see how they do.


    Thanks again!

-- 
Brad Knowles <brad@shub-internet.org> <http://www.shub-internet.org/brad/>

Are you a USENET news server administrator outside of North America or
Western Europe?  Would you like a newsfeed from a site in the Freenix
Top 100?  If so, please contact me via private e-mail for details.

Re: Diablo debugging problems...
#40348
Author: Russ Allbery
Date: Fri, 01 Oct 1999 00:00
21 lines
1315 bytes
N <niels@usenet.bakker.net> writes:
> Joe Greco wrote:

> [write() that makes sure all bytes were written]

>> If that works, I'll be irritated.

> There is a known "feature" in FreeBSD that causes write()s to be
> incomplete sometimes.  I *think* Matt Dillon worked around it in Diablo.

It's in the API definition of write().  You always have to do something
like this, or at least that's been the case in every brand of Unix I've
ever programmed on.

It *usually* works even if you don't check, but that 5% of the time when
it doesn't will invariably screw you over when you least expect it.

-- 
Russ Allbery (rra@stanford.edu)         <URL:http://www.eyrie.org/~eagle/>

Re: Diablo debugging problems...
#40361
Author: Joe Greco
Date: Fri, 01 Oct 1999 00:00
164 lines
6255 bytes
In news.software.nntp article <brad-0110991517500001@brad.techos.skynet.be>, brad@shub-internet.org (Brad Knowles) wrote:
:Folks,
:
:    I'm trying to use the Diablo "pipe" patch that Lars mentioned a couple
:of days ago, and I'm having some problems.  Specifically, filtering is
:occasionally dying unexpectedly.  I get error messages such as this in
:news.err:
:
:Oct  1 14:29:22 <news.err> seymour diablo[1268]: filter write failure:
:wanted to write 450523, wrote 393216: Undefined error: 0
:Oct  1 14:29:22 <news.err> seymour diablo[1268]: diab-filter: filter
:failed, write, sleeping for 4 seconds 
:Oct  1 14:29:22 <news.err> seymour diablo[1268]: filter exited on signal 91
:Oct  1 14:33:02 <news.err> seymour diablo[1268]: filter write failure:
:wanted to write 497437, wrote 393216: Undefined error: 0
:Oct  1 14:33:02 <news.err> seymour diablo[1268]: diab-filter: filter
:failed, write, sleeping for 9 seconds 
:Oct  1 14:33:02 <news.err> seymour diablo[1268]: filter exited on signal 29
:Oct  1 14:53:59 <news.err> seymour diablo[1268]: filter write failure:
:wanted to write 1004816, wrote 786432: Undefined error: 0
:Oct  1 14:53:59 <news.err> seymour diablo[1268]: diab-filter: filter
:failed, write, sleeping for 4 seconds 
:Oct  1 14:53:59 <news.err> seymour diablo[1268]: filter exited on signal 16
:
:    Now, I decided I'd take a look at what's going on with the daemon
:using truss, and relative to these errors, I see the following:
:
:syscall open("/news/spool/news/D.00eebe84/B.6c8b",0,00)
:        returns 6 (0x6)
:syscall lseek(6,0x449d7,0)
:        returns 281047 (0x449d7)
:syscall read(0x6,0x8138000,0x6c3e5)
:        returns 443365 (0x6c3e5)
:SIGNAL 20
:SIGNAL 20
:SIGNAL 20
:syscall write(164,0x8238000,450523)
:        returns 393216 (0x60000)
:syscall wait4(0xffffffff,0x0,0x1,0x0)
:        returns 1747 (0x6d3)
:syscall wait4(0xffffffff,0x0,0x1,0x0)
:        returns 0 (0x0)
:syscall sigreturn(0xbfbfd92c)
:        returns 393216 (0x60000)
:syscall gettimeofday(0xbfbfcd04,0x0)
:        returns 0 (0x0)
:syscall getpid()
:        returns 1268 (0x4f4)
:syscall sendto(0x3,0xbfbfd164,0x70,0x0,0x0,0x0)
:        returns 112 (0x70)
:
:    [ ... deletia ... ]
:
:syscall open("/news/spool/news/D.00eebe8e/B.2892",0,00)
:        returns 6 (0x6)
:syscall lseek(6,0x29858,0)
:        returns 170072 (0x29858)
:syscall read(0x6,0x8138000,0x77e1e)
:        returns 491038 (0x77e1e)
:SIGNAL 20
:SIGNAL 20
:SIGNAL 20
:syscall write(164,0x8238000,497437)
:        returns 393216 (0x60000)
:syscall wait4(0xffffffff,0x0,0x1,0x0)
:        returns 1793 (0x701)
:syscall wait4(0xffffffff,0x0,0x1,0x0)
:        returns 0 (0x0)
:syscall sigreturn(0xbfbfd92c)
:        returns 393216 (0x60000)
:syscall gettimeofday(0xbfbfcd04,0x0)
:        returns 0 (0x0)
:syscall getpid()
:        returns 1268 (0x4f4)
:syscall sendto(0x3,0xbfbfd164,0x70,0x0,0x0,0x0)
:        returns 112 (0x70)
:
:    [ ... deletia ... ]
:
:syscall open("/news/spool/news/D.00eebea2/B.2892",0,00)
:        returns 6 (0x6)
:syscall lseek(6,0x2d4f7a,0)
:        returns 2969466 (0x2d4f7a)
:syscall read(0x6,0x8138000,0xf16b3)
:        returns 988851 (0xf16b3)
:SIGNAL 20
:SIGNAL 20
:SIGNAL 20
:syscall write(174,0x8238000,1004816)
:        returns 786432 (0xc0000)
:syscall wait4(0xffffffff,0x0,0x1,0x0)
:        returns 2439 (0x987)
:syscall wait4(0xffffffff,0x0,0x1,0x0)
:        returns 2420 (0x974)
:syscall wait4(0xffffffff,0x0,0x1,0x0)
:        returns 1366 (0x556)
:syscall wait4(0xffffffff,0x0,0x1,0x0)
:        returns 1358 (0x54e)
:syscall wait4(0xffffffff,0x0,0x1,0x0)
:        returns 1357 (0x54d)
:syscall wait4(0xffffffff,0x0,0x1,0x0)
:        returns 0 (0x0)
:syscall sigreturn(0xbfbfd92c)
:        returns 786432 (0xc0000)
:syscall gettimeofday(0xbfbfcd04,0x0)
:        returns 0 (0x0)
:syscall getpid()
:        returns 1268 (0x4f4)
:syscall sendto(0x3,0xbfbfd164,0x71,0x0,0x0,0x0)
:        returns 113 (0x71)
:
:
:
:    Unfortunately, I'm totally at a loss to figure out what's going
:wrong.  The patch doesn't touch filter/diab-filter.c, nor does it touch
:anything else in filter/.
:
:    Anyone have any ideas of what I should do next to try and debug this
:problem?

Well, is your filter process _actually_ exiting, or not?  If so, what's 
causing it to do so? (*)

My "take" on this, is that somehow the pipe to the filter is getting
switched to non-blocking mode.  If this is so, you could do something
like nice 19 your filter process and the problem should happen fairly
quickly if you load down the box, even for smaller articles.

It could probably be fixed by wrapping write with a function that
requires all bytes to be written, although typically I don't recall
pipes having this sort of behaviour.

Try changing the write calls to "xwrite", and insert this at the top
of diab-filter.c.

int xwrite(fd, buf, siz)
int fd;
char *buf;
int siz;
{
	register int rval, chrs = 0;

	while (siz) {
		if ((rval = write(fd, buf, siz)) < 0) {
			return(rval);
		}
		chrs += rval;
		siz -= rval;
		buf += rval;
	}
	return(chrs);
}

If that works, I'll be irritated.

And since this snippet is written off the top of my head, it'll be wrong
and I'll have posted the embarrassing evidence of my incompetence as a C
programmer.  :-)  So I'll be irritated twice.

* I'm guessing that it's simply going away because diab-filter kills it.

... JG

Re: Diablo debugging problems...
#40388
Author: Brad Knowles
Date: Sat, 02 Oct 1999 00:00
20 lines
1699 bytes
In article <brad-0110992025530001@brad.techos.skynet.be>,
brad@shub-internet.org (Brad Knowles) wrote:

>     Well, I've been running that code now for over an hour, and I haven't
> had a single error like the ones I had previously reported.

    The code has now been running for several hours, and still no errors
like that.  I'm hoping that by the time it's had a chance to run for a
full day on Saturday, or perhaps by Sunday, I'll be able to see a
noticable performance improvement (my history should be largely built back
up by then).

-- 
Brad Knowles <brad@shub-internet.org> <http://www.shub-internet.org/brad/>

Are you a USENET news server administrator outside of North America or
Western Europe?  Would you like a newsfeed from a site in the Freenix
Top 100?  If so, please contact me via private e-mail for details.

Re: Diablo debugging problems...
#40424
Author: Brad Knowles
Date: Mon, 04 Oct 1999 00:00
25 lines
1959 bytes
In article <brad-0210990135450001@dialup519.brussels2.skynet.be>,
brad@shub-internet.org (Brad Knowles) wrote:

>             I'm hoping that by the time it's had a chance to run for a
> full day on Saturday, or perhaps by Sunday, I'll be able to see a
> noticable performance improvement (my history should be largely built back
> up by then).

    Well, it's been running over the weekend, and as far as that part of
the code is concerned, it seems to be running just fine.  However, if you
look at our stats, you will notice that we no longer have any "SPAM
activity" that we are logging any information about.  It would appear to
me that the filter code either isn't running or isn't running properly,
and might be silently dying.

    Sigh....

-- 
Brad Knowles <brad@shub-internet.org> <http://www.shub-internet.org/brad/>

Are you a USENET news server administrator outside of North America or
Western Europe?  Would you like a newsfeed from a site in the Freenix
Top 100?  If so, please contact me via private e-mail for details.

Re: Diablo debugging problems...
#40428
Author: Brad Knowles
Date: Mon, 04 Oct 1999 00:00
18 lines
1576 bytes
In article <yl670ndpwz.fsf@windlord.stanford.edu>, Russ Allbery
<rra@stanford.edu> wrote:

> In this case it contains 0, which syslog() (probably via strerror())
> recognizes as not being an actual error code, producing the "Undefined
> error" message.

    Ahh, I see.  So I need to check the return code before I send that to
syslog, so that I don't log an unnecessary error.

-- 
Brad Knowles <brad@shub-internet.org> <http://www.shub-internet.org/brad/>

Are you a USENET news server administrator outside of North America or
Western Europe?  Would you like a newsfeed from a site in the Freenix
Top 100?  If so, please contact me via private e-mail for details.

Re: Diablo debugging problems...
#40461
Author: Russ Allbery
Date: Mon, 04 Oct 1999 00:00
23 lines
1592 bytes
Brad Knowles <brad@shub-internet.org> writes:
> Russ Allbery <rra@stanford.edu> wrote:

>> In this case it contains 0, which syslog() (probably via strerror())
>> recognizes as not being an actual error code, producing the "Undefined
>> error" message.

> Ahh, I see.  So I need to check the return code before I send that to
> syslog, so that I don't log an unnecessary error.

Yeah, in general you only log with %m or use strerror() or perror() or
what have you if some system call failed and it's documented to set
errno.  Otherwise, the value may be some unuseful junk left over from
something else.

In the code you were quoting, the return value of write() had already been
checked and I don't believe the syslog() call was reachable if write() had
returned -1.

-- 
Russ Allbery (rra@stanford.edu)         <URL:http://www.eyrie.org/~eagle/>

Re: Diablo debugging problems...
#40468
Author: Russell Vincent
Date: Mon, 04 Oct 1999 00:00
15 lines
1223 bytes
Brad Knowles <brad@shub-internet.org> wrote:

>     It would seem to me that the "%m" on that call to syslog() should be
> removed, so as to eliminate the "Undefined error: 0" portion of the
> message.

The %m is the "Undefined error: 0" part. It means "print the string
version of the last error".

Shall we staple the pointy hat to your head?  :-)

 -Russell


Re: Diablo debugging problems...
#40470
Author: Brad Knowles
Date: Mon, 04 Oct 1999 00:00
16 lines
1423 bytes
In article <7tamb6$cvo$1@wave.pipex.net>, Russell Vincent
<russellv-n@nosp.uk.uu.net> wrote:

> Shall we staple the pointy hat to your head?  :-)

    I'm not sure that will be necessary.  It seems to have made a
permanent home anyway.

-- 
Brad Knowles <brad@shub-internet.org> <http://www.shub-internet.org/brad/>

Are you a USENET news server administrator outside of North America or
Western Europe?  Would you like a newsfeed from a site in the Freenix
Top 100?  If so, please contact me via private e-mail for details.

Re: Diablo debugging problems...
#40472
Author: Russ Allbery
Date: Mon, 04 Oct 1999 00:00
28 lines
1897 bytes
Brad Knowles <brad@shub-internet.org> writes:

> However, I'm rather confused by the "...: %m" argument being handed to
> syslog().  It's replicated throughout all syslog calls I can find in
> this code, and yet there doesn't seem to be a corresponding value being
> printed with that "%m" format, nor can I find that format in the man
> page for the printf() family.

It's a special syslog() thing, not a printf() thing, and it doesn't take
an argument:

     The message body is generated from the message and following
     arguments in the same manner as if these were arguments to
     printf(3B), except that occurrences of %m in the format string
     pointed to by the message argument are replaced by the error message
     string associated with the current value of errno.

Of course, write() didn't return -1 but rather returned a zero or positive
value that was just less than the expected one.  Therefore, per the write
API documentation, errno was not set and will contain something random.
In this case it contains 0, which syslog() (probably via strerror())
recognizes as not being an actual error code, producing the "Undefined
error" message.

-- 
Russ Allbery (rra@stanford.edu)         <URL:http://www.eyrie.org/~eagle/>

Re: Diablo debugging problems...
#40477
Author: Brad Knowles
Date: Mon, 04 Oct 1999 00:00
63 lines
2967 bytes
In article <37f4e0b3$0$10188@news.execpc.com>, jgreco@ns.sol.net (Joe
Greco) wrote:

> Try changing the write calls to "xwrite", and insert this at the top
> of diab-filter.c.

    Based on the other code in diab-filter.c, I added the following:

> int xwrite(fd, buf, siz)
> int fd;
> char *buf;
> int siz;
> {
>         register int rval, chrs = 0;
> 
>         while (siz) {
>                 if ((rval = write(fd, buf, siz)) < 0) {
>                         return(rval);
>                 }

                if (siz > rval) {
                        syslog(LOG_WARNING, "filter partial success: wanted to w
rite %d, wrote %d: %m", siz, rval);
                }
>                 chrs += rval;
>                 siz -= rval;
>                 buf += rval;
>         }
>         return(chrs);
> }

    However, I'm rather confused by the "...: %m" argument being handed to
syslog().  It's replicated throughout all syslog calls I can find in this
code, and yet there doesn't seem to be a corresponding value being printed
with that "%m" format, nor can I find that format in the man page for the
printf() family.

    On output, I get the following:

Oct  4 17:28:10 seymour diablo[43889]: filter partial success: wanted to
write 131903, wrote 131072: Undefined error: 0
Oct  4 17:30:39 seymour diablo[43889]: filter partial success: wanted to
write 30240, wrote 131072: Undefined error: 0
Oct  4 18:00:10 seymour diablo[44559]: filter partial success: wanted to
write 182901, wrote 65536 : Undefined error: 0
Oct  4 18:20:31 seymour diablo[44559]: filter partial success: wanted to
write 107920, wrote 65536 : Undefined error: 0

    It would seem to me that the "%m" on that call to syslog() should be
removed, so as to eliminate the "Undefined error: 0" portion of the
message.


    Am I missing something here?

-- 
Brad Knowles <brad@shub-internet.org> <http://www.shub-internet.org/brad/>

Are you a USENET news server administrator outside of North America or
Western Europe?  Would you like a newsfeed from a site in the Freenix
Top 100?  If so, please contact me via private e-mail for details.

Re: Diablo debugging problems...
#40489
Author: Joe Greco
Date: Mon, 04 Oct 1999 00:00
10 lines
1321 bytes
In news.software.nntp article <brad-0510990113060001@dialup1042.brussels2.skynet.be>, brad@shub-internet.org (Brad Knowles) wrote:
:    Blech.  it just occured to me -- I'm doing a blocking write on every
:single article, when sending it to the spamfilter.  Double blech.

You weren't paying *ATTENTION* (snaps the ruler on Brad's desk) when I
explained this in the last round of filter discussions.  :-)

... JG

Re: Diablo debugging problems...
#40493
Author: Joe Greco
Date: Tue, 05 Oct 1999 00:00
38 lines
2802 bytes
In news.software.nntp article <brad-0510991730300001@brad.techos.skynet.be>, brad@shub-internet.org (Brad Knowles) wrote:
:In article <brad-0510991348210001@brad.techos.skynet.be>,
:brad@shub-internet.org (Brad Knowles) wrote:
:
:>    I know that the routine is being put into the library and the binaries
:> are being linked agains that library, but until I see one of those lines
:> logged, I can't be sure that the program is actually using it.
:
:    Sigh....  Stupid me, when I moved the routine, I didn't do an xmake
:clean.  So it was never really put in the library, and therefore wasn't
:being called.  When I finally did an xmake clean and then put the new set
:of binaries into production, it locked up pretty fast.
:
:    The man page for write(2) says that the second argument is a "const
:void *", while all of the routines I can find that use it in Diablo
:actually call it with a "const char *" or a "char *" in the second
:argument.
:
:    I'm going to try to do some more debugging and figure out if I can
:find a proper cast for the second argument for xwrite(), one that won't
:cause gcc to complain (too much), and one that hopefully won't cause those
:signal 11's.

I'm curious why you're even trying to do this.  Most of Diablo is going to
be writing to disk (which won't need xwrite) or is using Matt's buffered
I/O library (which'll probably break if you use xwrite), and the only thing
that xwrite was meant to fix was an assumption I made in diab-filter about
IPC behaviour which may or may not be true.

I'm actually tempted to go look at POSIX for more info.  Solaris man pages
for write(2) suggest that write is guaranteed to write the bytes, assuming
neither O_NONBLOCK nor O_NDELAY are set on the fd.  I've seen some other
mildly supporting stuff...  it might be more interesting just to play with
the fd's mode to correct the behaviour.

... JG

Re: Diablo debugging problems...
#40498
Author: Brad Knowles
Date: Tue, 05 Oct 1999 00:00
29 lines
1967 bytes
In article <37fa44dc$0$7740@news.execpc.com>, jgreco@ns.sol.net (Joe
Greco) wrote:

> I'm curious why you're even trying to do this.

    Well, remember that I'm running the PIPE patches, and the point was
made to me that I should make the same changes to them as I did for
diab-filter.c.  I thought I'd be bright, and actually just apply the patch
across the board, assuming that the same changes needed to be made
everywhere.

    Obviously this is not the case, and although it might be useful to
move xwrite() to a library and call it from the pipe modified version of
diablo() and diab-filter, it's *not* something that should be applied
globally.


    I'll probably play with this some more tomorrow, but I'm certainly not
going to do anything more with it tonight.

-- 
Brad Knowles <brad@shub-internet.org> <http://www.shub-internet.org/brad/>
    <http://wwwkeys.pgp.net:11371/pks/lookup?op=get&search=0xE38CCEF1>

Are you a USENET news server administrator outside of North America or
Western Europe?  Would you like a newsfeed from a site in the Freenix
Top 100?  If so, please contact me via private e-mail for details.

Re: Diablo debugging problems...
#40502
Author: Brad Knowles
Date: Tue, 05 Oct 1999 00:00
30 lines
2386 bytes
In article <brad-0510991317560001@brad.techos.skynet.be>,
brad@shub-internet.org (Brad Knowles) wrote:

>     Blargh.  There are 67 different places in various pieces of Diablo
> source code where write() is called.  I guess the easy way to fix this
> problem is to define the xwrite() routine in lib/xwrite.c, make sure that
> all objects are linked against it, and then do a #define in defs.h (or
> perhaps vendor.h?) that ensures that all calls to write() actually go to
> xwrite().

    Well, I'm just guessing, but the code appeared to compile correctly
and appears to be running okay, so far.  I've only had it up for a few
minutes, and have yet to see my first syslog() output from the new
xwrite() library routine.

   I know that the routine is being put into the library and the binaries
are being linked agains that library, but until I see one of those lines
logged, I can't be sure that the program is actually using it.


     We'll let it run for a while and see what happens.

-- 
Brad Knowles <brad@shub-internet.org> <http://www.shub-internet.org/brad/>

Are you a USENET news server administrator outside of North America or
Western Europe?  Would you like a newsfeed from a site in the Freenix
Top 100?  If so, please contact me via private e-mail for details.

Re: Diablo debugging problems...
#40512
Author: Brad Knowles
Date: Tue, 05 Oct 1999 00:00
19 lines
1764 bytes
In article <37f9552b$0$10179@news.execpc.com>, jgreco@ns.sol.net (Joe
Greco) wrote:

> You weren't paying *ATTENTION* (snaps the ruler on Brad's desk) when I
> explained this in the last round of filter discussions.  :-)

    I don't usually fully understand something unless I get my hands dirty
inside the code, or I spend a lot of time building a system from certain
components, pretty much from the ground up.  The more I learn about
Diablo, the more I learn how very little I really know about it.

-- 
Brad Knowles <brad@shub-internet.org> <http://www.shub-internet.org/brad/>

Are you a USENET news server administrator outside of North America or
Western Europe?  Would you like a newsfeed from a site in the Freenix
Top 100?  If so, please contact me via private e-mail for details.

Re: Diablo debugging problems...
#40516
Author: Brad Knowles
Date: Tue, 05 Oct 1999 00:00
30 lines
2507 bytes
In article <brad-0510990113060001@dialup1042.brussels2.skynet.be>,
brad@shub-internet.org (Brad Knowles) wrote:

>     Anyway, now I just have to retrofit this xwrite() routine to all the
> places that currently call write(), and probably move xwrite() to
> something in lib/ (with suitable additions to the appropriate header
> files, etc...), so that I can use it everywhere.

    Blargh.  There are 67 different places in various pieces of Diablo
source code where write() is called.  I guess the easy way to fix this
problem is to define the xwrite() routine in lib/xwrite.c, make sure that
all objects are linked against it, and then do a #define in defs.h (or
perhaps vendor.h?) that ensures that all calls to write() actually go to
xwrite().

    Blech.  This reminds me of what Eric had to do to fix sendmail to use
a private "hard_syslog()" routine on OSes where syslog() doesn't guarantee
success (such as HP-UX).  Only it'll be slightly different for me, since
there's no simple catch-all library or header files that appear to be
obvious places to dump something like this, entailing modifications to the
XMakefile.inc as well as everything else.

-- 
Brad Knowles <brad@shub-internet.org> <http://www.shub-internet.org/brad/>

Are you a USENET news server administrator outside of North America or
Western Europe?  Would you like a newsfeed from a site in the Freenix
Top 100?  If so, please contact me via private e-mail for details.

Re: Diablo debugging problems...
#40527
Author: Miquel van Smoorenburg
Date: Tue, 05 Oct 1999 00:00
24 lines
1937 bytes
In article <37fa44dc$0$7740@news.execpc.com>,
Joe Greco <jgreco@ns.sol.net> wrote:
>I'm actually tempted to go look at POSIX for more info.  Solaris man pages
>for write(2) suggest that write is guaranteed to write the bytes, assuming
>neither O_NONBLOCK nor O_NDELAY are set on the fd.  I've seen some other
>mildly supporting stuff...  it might be more interesting just to play with
>the fd's mode to correct the behaviour.

To disk - probably, as long as the write is just a few pages. If you
want to write 512 MB using write() in one go chances are that it
will not write it in one system call.

If you write() to a pipe or a socket, the write might be partial if
the kernel buffer has filled up because the other side hasn't read
all the data yet, or you write more data than the kernel buffer size.
Kernel buffer size of a pipe() is usually smaller
than that of a socket (4K vs 32K or so) except on systems where
a pipe() is actually a socketpair() (like Solaris, I think).

Mike.
-- 
First things first, but not necessarily in that order.

Re: Diablo debugging problems...
#40528
Author: Miquel van Smoorenburg
Date: Tue, 05 Oct 1999 00:00
15 lines
1373 bytes
In article <brad-0510991730300001@brad.techos.skynet.be>,
Brad Knowles <brad@shub-internet.org> wrote:
>    The man page for write(2) says that the second argument is a "const
>void *", while all of the routines I can find that use it in Diablo
>actually call it with a "const char *" or a "char *" in the second
>argument.

Yes, so ? I guess it has been a long time since you did some C programming,
right ? ;)

Mike.
-- 
First things first, but not necessarily in that order.

Re: Diablo debugging problems...
#40534
Author: Brad Knowles
Date: Tue, 05 Oct 1999 00:00
40 lines
2612 bytes
In article <ylg0zqaja4.fsf@windlord.stanford.edu>, Russ Allbery
<rra@stanford.edu> wrote:

> In the code you were quoting, the return value of write() had already been
> checked and I don't believe the syslog() call was reachable if write() had
> returned -1.

    I just had the bright idea that it might be nice if this code was
smart and would loop only a limited number of times before returning, and
if it couldn't write everything it was asked to, the calling routine
should deal with the error.

    Of course, I think these are blocking write() calls, so I would be
very surprised if the routine ever looped more than twice, but still it's
a good idea.  For now, I've set it to break out at 100 times through the
loop, but I'm thinking I should lower that number to something more like
five.


    Blech.  it just occured to me -- I'm doing a blocking write on every
single article, when sending it to the spamfilter.  Double blech.


    Anyway, now I just have to retrofit this xwrite() routine to all the
places that currently call write(), and probably move xwrite() to
something in lib/ (with suitable additions to the appropriate header
files, etc...), so that I can use it everywhere.


    Man, I wish I knew why I wasn't getting anything but
spamfilter-by-body messages anymore....

-- 
Brad Knowles <brad@shub-internet.org> <http://www.shub-internet.org/brad/>

Are you a USENET news server administrator outside of North America or
Western Europe?  Would you like a newsfeed from a site in the Freenix
Top 100?  If so, please contact me via private e-mail for details.

Re: Diablo debugging problems...
#40539
Author: Kjetil Torgrim Homme
Date: Tue, 05 Oct 1999 00:00
57 lines
2876 bytes
[Brad Knowles]

>       Well, remember that I'm running the PIPE patches, and the
>   point was made to me that I should make the same changes to them
>   as I did for diab-filter.c.

The PIPE-patch was intended to handle the return value from write/read
correctly, and will probably break if you substitute all write()s for
xwrite().

I see now that this is not the case in flushPipedFeeds(), but since it
is only called when shutting down Diablo, it shouldn't be the source
of your problem.  This one, in util/dnewslink.c, is more likely:

#ifdef PIPE
        } else {
          if (PipeOpt)
            /* Notify parent diablo process that we have read this line */
            write (2, &n, sizeof(n));    
#endif

It is possible that this fails due to interrupted system calls,
resulting in 0 bytes written and communication out of whack.  Geez,
this may be the cause of some problem reports from a FreeBSD user
which tried our code.  (We run Solaris, but it's probably just luck
that it hasn't hit us.)

The attached patch has been running satisfactorily for 15 seconds.


Kjetil T.

--- util/dnewslink.c.orig       Tue Oct  5 22:39:24 1999
+++ util/dnewslink.c    Tue Oct  5 22:46:32 1999
@@ -2208,9 +2208,18 @@
            }
 #ifdef PIPE
         } else {
-          if (PipeOpt)
+          if (PipeOpt) {
+           int ret, offset = 0;
             /* Notify parent diablo process that we have read this line */
-           write (2, &n, sizeof(n));
+            do {
+             ret = write (2, (char *) &n + offset , sizeof(n) - offset);
+             if (ret == -1 && errno != EAGAIN) {
+               dl_logit("write failed: %s\n", strerror(errno));
+               exit (1);
+             }
+             offset += ret;
+           } while (offset != sizeof(n));
+         }
 #endif
        }
        rbs->rb_Len += n;

Re: Diablo debugging problems...
#40542
Author: Kjetil Torgrim Homme
Date: Tue, 05 Oct 1999 00:00
33 lines
2222 bytes
[Joe Greco]

>   I'm actually tempted to go look at POSIX for more info.  Solaris
>   man pages for write(2) suggest that write is guaranteed to write
>   the bytes, assuming neither O_NONBLOCK nor O_NDELAY are set on the
>   fd.

Well, the Solaris man page clearly states:

     If a write() requests that more bytes be written than  there
     is  room for-for example, if the write would exceed the pro-
     cess file size limit (see getrlimit(2) and  ulimit(2)),  the
     system file size limit, or the free space on the device-only
     as many bytes as there is room for  will  be  written.   For
     example,  suppose there is space for 20 bytes more in a file
     before reaching a limit.  A write() of 512-bytes returns 20.
     The  next  write()  of  a  non-zero  number of bytes gives a
     failure return (except as noted for pipes and FIFO below).

     If write() is interrupted by a signal before it  writes  any
     data, it will return -1 with errno set to EINTR.

     If write() is interrupted by a signal after it  successfully
     writes  some  data, it will return the number of bytes writ-
     ten.

So it quite is pertinent to check for the return value.  Receiving
SIGCHLD while writing isn't that unlikely.


Kjetil T.

Re: Diablo debugging problems...
#40543
Author: bill davidsen
Date: Tue, 05 Oct 1999 00:00
30 lines
2150 bytes
In article <7tdf9o$v9t$1@defiant.cistron.net>,
Miquel van Smoorenburg <miquels@cistron.nl> wrote:
| In article <brad-0510991730300001@brad.techos.skynet.be>,
| Brad Knowles <brad@shub-internet.org> wrote:
| >    The man page for write(2) says that the second argument is a "const
| >void *", while all of the routines I can find that use it in Diablo
| >actually call it with a "const char *" or a "char *" in the second
| >argument.
| 
| Yes, so ? I guess it has been a long time since you did some C programming,
| right ? ;)

  Or a long time since anyone ran the code through a compiler which
complains about type mismatches. The size and format of all pointers is
the same on most machines, but not all. I wouldn't expect this to be a
problem, but I like to run through several compilers set to be totally
anal before I let the code out. It sometimes keeps it from coming back
;-)

  Don't kid Brad for reading the manual, there are only seven people in
the world who do, and they keep the publishing industry alive.

-- 
bill davidsen <davidsen@tmr.com>  CTO, TMR Associates, Inc
  When taking small children to a carnival, always have them go potty
*before* you let them go on the rides, and let them eat all the junk
food and candy *after*.


Re: Diablo debugging problems...
#40550
Author: Brad Knowles
Date: Tue, 05 Oct 1999 00:00
19 lines
1613 bytes
In article <ylg0zqaja4.fsf@windlord.stanford.edu>, Russ Allbery
<rra@stanford.edu> wrote:

> In the code you were quoting, the return value of write() had already been
> checked and I don't believe the syslog() call was reachable if write() had
> returned -1.

    Correct.  I'll pull out that "%m" format.

    Thanks!

-- 
Brad Knowles <brad@shub-internet.org> <http://www.shub-internet.org/brad/>

Are you a USENET news server administrator outside of North America or
Western Europe?  Would you like a newsfeed from a site in the Freenix
Top 100?  If so, please contact me via private e-mail for details.

Re: Diablo debugging problems...
#40552
Author: Brad Knowles
Date: Tue, 05 Oct 1999 00:00
18 lines
1508 bytes
In article <7tdf9o$v9t$1@defiant.cistron.net>, miquels@cistron.nl (Miquel
van Smoorenburg) wrote:

> Yes, so ? I guess it has been a long time since you did some C programming,
> right ? ;)

    Yeah, I told you -- ten years.  It's not exactly easy trying to get
back on a bicycle after having not ridden one for that long.

-- 
Brad Knowles <brad@shub-internet.org> <http://www.shub-internet.org/brad/>
    <http://wwwkeys.pgp.net:11371/pks/lookup?op=get&search=0xE38CCEF1>

Are you a USENET news server administrator outside of North America or
Western Europe?  Would you like a newsfeed from a site in the Freenix
Top 100?  If so, please contact me via private e-mail for details.

Re: Diablo debugging problems...
#40556
Author: Brad Knowles
Date: Tue, 05 Oct 1999 00:00
43 lines
2998 bytes
In article <brad-0510991348210001@brad.techos.skynet.be>,
brad@shub-internet.org (Brad Knowles) wrote:

>    I know that the routine is being put into the library and the binaries
> are being linked agains that library, but until I see one of those lines
> logged, I can't be sure that the program is actually using it.

    Sigh....  Stupid me, when I moved the routine, I didn't do an xmake
clean.  So it was never really put in the library, and therefore wasn't
being called.  When I finally did an xmake clean and then put the new set
of binaries into production, it locked up pretty fast.

    The man page for write(2) says that the second argument is a "const
void *", while all of the routines I can find that use it in Diablo
actually call it with a "const char *" or a "char *" in the second
argument.

    I also apparently found a single-bit memory error around the same time
-- 2B0D6000h (fortunately, I have ECC RAM).  I hit the reset switch and
the machine rebooted, but then diablo child processes started dying
regularly with signal 11's.  I've put the old binary back into production.


    I'm going to try to do some more debugging and figure out if I can
find a proper cast for the second argument for xwrite(), one that won't
cause gcc to complain (too much), and one that hopefully won't cause those
signal 11's.

    I'm also going to have to see if we've got a maintenance contract for
these machines and see if I can get the memory replaced where we found the
single-bit error.


    Blargh.  This is really annoying.

-- 
Brad Knowles <brad@shub-internet.org> <http://www.shub-internet.org/brad/>

Are you a USENET news server administrator outside of North America or
Western Europe?  Would you like a newsfeed from a site in the Freenix
Top 100?  If so, please contact me via private e-mail for details.

Re: Diablo debugging problems...
#40565
Author: Brad Knowles
Date: Wed, 06 Oct 1999 00:00
25 lines
1961 bytes
In article <n3CK3.4224$L85.331333@ptah.visi.com>, drechsau+usenet@yuck.net
(Mike Horwath) wrote:

> And this is why I am waiting for Mr. Joe Greco to do the work for me.

    Smart idea.

> No offense, but you should take the same track :)

    If I did that, I'd never learn.  And as busy as Joe is, I doubt much
real progress would occur any time soon on the public version of Diablo.

    Somebody somewhere has to be hacking on it for there to be any
progress (now that Matt's more involved in FreeBSD, he just doesn't have
the time or inclination any more), and I figure I might as well try to
learn something in the process.

-- 
Brad Knowles <brad@shub-internet.org> <http://www.shub-internet.org/brad/>

Are you a USENET news server administrator outside of North America or
Western Europe?  Would you like a newsfeed from a site in the Freenix
Top 100?  If so, please contact me via private e-mail for details.

Re: Diablo debugging problems...
#40573
Author: Stephen R. van den Berg
Date: Wed, 06 Oct 1999 00:00
31 lines
1812 bytes
Joe Greco <jgreco@ns.sol.net> wrote:
>I'm curious why you're even trying to do this.  Most of Diablo is going to
>be writing to disk (which won't need xwrite) or is using Matt's buffered
>I/O library (which'll probably break if you use xwrite), and the only thing

Basically, check the returnvalue of write() everytime, even for disk I/O,
for two reasons:
- Depending on the underlying disk subsystem, it might return with less than
  what you requested to be written.
- If a signal (any signal) arrives, the write will return early, and will
  need to be restarted.

This is what I usually use as a "reliable"-write():

int rwrite(const int fd,char*a,const unsigned len)
{ int i;size_t left=len;
  do
     while(0>(i=write(fd,a,left))&&errno==EINTR);
  while(i>0&&(a+=i,left-=i));
  return len-left;
}

Add whitespace to taste.
It's less filling and POSIXly correct.
-- 
Sincerely,                                                          srb@cuci.nl
           Stephen R. van den Berg (AKA BuGless).

A truly wise man never plays leapfrog with a unicorn.

Re: Diablo debugging problems...
#40585
Author: Russ Allbery
Date: Wed, 06 Oct 1999 00:00
14 lines
1297 bytes
Brad Knowles <brad@shub-internet.org> writes:

> Well, what I think I really need is Harbison & Steele, as well as the
> Stevens books.  I don't think I ever had any of these.  The only
> "systems programming" book I ever recall having was Salama.

You definitely want Stevens.  Both Advanced Programming in the Unix
Environment and both volumes of Unix Network Programming, and TCP/IP
Illustrated too if you have some spare cash.  Fantastic books.

-- 
Russ Allbery (rra@stanford.edu)         <URL:http://www.eyrie.org/~eagle/>

Re: Diablo debugging problems...
#40586
Author: Russ Allbery
Date: Wed, 06 Oct 1999 00:00
12 lines
1203 bytes
Mike Horwath <drechsau+usenet@yuck.net> writes:

> And this is why I am waiting for Mr. Joe Greco to do the work for me.
> No offense, but you should take the same track :)

Nah, don't discourage him.  More people hacking news software who are
willing to donate their code to the rest of us is a good thing!

-- 
Russ Allbery (rra@stanford.edu)         <URL:http://www.eyrie.org/~eagle/>

Re: Diablo debugging problems...
#40598
Author: Stephen R. van den Berg
Date: Wed, 06 Oct 1999 00:00
25 lines
1735 bytes
Brad Knowles <brad@shub-internet.org> wrote:
>    I've got a boatload of O'Reilly books, and I do actually own a real
>1st edition K&R (somewhere), and a few other books on programming in C. 

Get the 2nd edition, it's worth it.

>However, since it's been ten years since I did anything in that arena,
>I've got two problems:

>        2)  Even if I could find the books, odds are that they won't
>address what is now considered to be more advanced C programming, such as
>threads, aio, etc....  About the best that could be expected of them would
>be that they would cover fork() and exec() and some of the variants
>thereof.

AFAIK, there *still* are no good books which cover threads and aio.
You do seem to have missed the ANSI-fication of C.  Which is
covered in the 2nd edition of K&R.
-- 
Sincerely,                                                          srb@cuci.nl
           Stephen R. van den Berg (AKA BuGless).

A truly wise man never plays leapfrog with a unicorn.

Re: Diablo debugging problems...
#40601
Author: Brad Knowles
Date: Wed, 06 Oct 1999 00:00
23 lines
1774 bytes
In article <7tec44$j8i$1@zeus.fw.cuci.nl>, srb@cuci.nl (Stephen R. van den
Berg) wrote:

> Get the 2nd edition, it's worth it.

    I think I've got a copy of that, too.

> AFAIK, there *still* are no good books which cover threads and aio.
> You do seem to have missed the ANSI-fication of C.  Which is
> covered in the 2nd edition of K&R.

    Well, what I think I really need is Harbison & Steele, as well as the
Stevens books.  I don't think I ever had any of these.  The only "systems
programming" book I ever recall having was Salama.

-- 
Brad Knowles <brad@shub-internet.org> <http://www.shub-internet.org/brad/>

Are you a USENET news server administrator outside of North America or
Western Europe?  Would you like a newsfeed from a site in the Freenix
Top 100?  If so, please contact me via private e-mail for details.

Re: Diablo debugging problems...
#40604
Author: Richard Kettlewell
Date: Wed, 06 Oct 1999 00:00
18 lines
1335 bytes
davidsen@tmr.com (bill davidsen) writes:

> Or a long time since anyone ran the code through a compiler which
> complains about type mismatches. The size and format of all pointers
> is the same on most machines, but not all.

`char *' and `void *' are required to have the same representation,
however.

> Don't kid Brad for reading the manual, there are only seven people
> in the world who do, and they keep the publishing industry alive.

Quite...

-- 
http://www.greenend.org.uk/rjk/

Re: Diablo debugging problems...
#40605
Author: Brad Knowles
Date: Wed, 06 Oct 1999 00:00
37 lines
2625 bytes
In article <7tdsvu$uil$1@newssvr02.news.prodigy.com>, davidsen@tmr.com
(bill davidsen) wrote:

>   Or a long time since anyone ran the code through a compiler which
> complains about type mismatches.

    Oh, there's plenty of complaints in there.  It's long since past time
that lint was run on this puppy.  However, I see so many warnings that
I've gotten to the point where I ignore anything short of an actual
compile-time error.  I guess this isn't exactly the right idea.  ;-)

>   Don't kid Brad for reading the manual, there are only seven people in
> the world who do, and they keep the publishing industry alive.

    I've got a boatload of O'Reilly books, and I do actually own a real
1st edition K&R (somewhere), and a few other books on programming in C. 
However, since it's been ten years since I did anything in that arena,
I've got two problems:

        1)  They're probably still in Oklahoma, and my parents have long
since moved to Tennessee (of course, I moved to DC after I finished my
degree ten years ago, and have since moved to Belgium).

        2)  Even if I could find the books, odds are that they won't
address what is now considered to be more advanced C programming, such as
threads, aio, etc....  About the best that could be expected of them would
be that they would cover fork() and exec() and some of the variants
thereof.

-- 
Brad Knowles <brad@shub-internet.org> <http://www.shub-internet.org/brad/>

Are you a USENET news server administrator outside of North America or
Western Europe?  Would you like a newsfeed from a site in the Freenix
Top 100?  If so, please contact me via private e-mail for details.

Re: Diablo debugging problems...
#40606
Author: Russ Allbery
Date: Wed, 06 Oct 1999 00:00
16 lines
1449 bytes
Brad Knowles <brad@shub-internet.org> writes:

> This is very close to the xwrite() routine that Joe posted, but neither
> of these take into account the fact that you should only go through this
> loop so many times before you drop out.  If you don't have a method of
> giving up when things get hopelessly slow, you can bog down the whole
> system waiting on a single write() to complete.

Well, to be fair, I've never seen that behavior from write(), so I think
you may be worrying about an error condition that never happens in
practice.  But it's a point, and it's theoretically possible I suppose.

-- 
Russ Allbery (rra@stanford.edu)         <URL:http://www.eyrie.org/~eagle/>

Re: Diablo debugging problems...
#40616
Author: Brad Knowles
Date: Wed, 06 Oct 1999 00:00
27 lines
1913 bytes
In article <7tebo8$hta$1@zeus.fw.cuci.nl>, srb@cuci.nl (Stephen R. van den
Berg) wrote:

> This is what I usually use as a "reliable"-write():
> 
> int rwrite(const int fd,char*a,const unsigned len)
> { int i;size_t left=len;
>   do
>      while(0>(i=write(fd,a,left))&&errno==EINTR);
>   while(i>0&&(a+=i,left-=i));
>   return len-left;
> }

    This is very close to the xwrite() routine that Joe posted, but
neither of these take into account the fact that you should only go
through this loop so many times before you drop out.  If you don't have a
method of giving up when things get hopelessly slow, you can bog down the
whole system waiting on a single write() to complete.

-- 
Brad Knowles <brad@shub-internet.org> <http://www.shub-internet.org/brad/>

Are you a USENET news server administrator outside of North America or
Western Europe?  Would you like a newsfeed from a site in the Freenix
Top 100?  If so, please contact me via private e-mail for details.

Re: Diablo debugging problems...
#40625
Author: Brad Knowles
Date: Thu, 07 Oct 1999 00:00
18 lines
1740 bytes
In article <yln1twf21z.fsf@windlord.stanford.edu>, Russ Allbery
<rra@stanford.edu> wrote:

> You definitely want Stevens.  Both Advanced Programming in the Unix
> Environment and both volumes of Unix Network Programming, and TCP/IP
> Illustrated too if you have some spare cash.  Fantastic books.

    It's a shame I can't register for them at amazon.com for my upcoming
wedding, but I think my fianc�e would be upset.  ;-)

-- 
Brad Knowles <brad@shub-internet.org> <http://www.shub-internet.org/brad/>

Are you a USENET news server administrator outside of North America or
Western Europe?  Would you like a newsfeed from a site in the Freenix
Top 100?  If so, please contact me via private e-mail for details.

Re: Diablo debugging problems...
#40667
Author: Russ Allbery
Date: Fri, 08 Oct 1999 00:00
19 lines
1541 bytes
Kjetil Torgrim Homme <kjetilho@haey.ifi.uio.no> writes:
> [Russ Allbery]

>>   Well, to be fair, I've never seen that behavior from write(), so I
>>   think you may be worrying about an error condition that never
>>   happens in practice.  But it's a point, and it's theoretically
>>   possible I suppose.

> A loop with ENOSPC or EBADF (a bug elsewhere in the code) can happen.

No, the error case was already handled separately.  Brad was talking about
limiting the number of times the code would loop on partial writes that
weren't returning errors.  I really don't think that will ever loop
forever on a sane system.

-- 
Russ Allbery (rra@stanford.edu)         <URL:http://www.eyrie.org/~eagle/>

Re: Diablo debugging problems...
#40674
Author: Joe Greco
Date: Fri, 08 Oct 1999 00:00
41 lines
2964 bytes
In news.software.nntp article <37fe9461$0$11999@master.news.zetnet.net>, pm@nowster-zetnet.co.uk (Paul Martin) wrote:
:In article <brad-0710991318130001@brad.techos.skynet.be>, Brad Knowles wrote:
:>In article <yln1twf21z.fsf@windlord.stanford.edu>, Russ Allbery
:><rra@stanford.edu> wrote:
:>
:>> You definitely want Stevens.  Both Advanced Programming in the Unix
:>> Environment and both volumes of Unix Network Programming, and TCP/IP
:>> Illustrated too if you have some spare cash.  Fantastic books.
:>
:>    It's a shame I can't register for them at amazon.com for my upcoming
:>wedding, but I think my fianc�e would be upset.  ;-)
:
:I got my copies from Amazon. (Not the TCP/IP books, though. I'll get those
:when I have a bit more spare cash, I bought the TAOCP set [Knuth] at the
:same time.) Very useful they are too.
:
:Thoughts on Diablo... it uses mmap() extensively internally. Perhaps an
:optimization would be for the filter interface to receive the filename,
:offset and length of the article that's to be examined, then passes that
:info into the filter, which does an mmap(...,PROT_READ,MAP_SHARED,..) with
:the article (this would require writing a perl module to handle mmap) 
:then mapped to a Perl scalar. That would then provide an environment not
:unlike INN for a filter. The kernel would (should) mmap the same memory
:area that diablo holds the article in, and there's very little copying
:involved.
:
:This is straight off the top of my head, and I'm certainly happy to be
:shot down in flames. 

Fantastic, another Stupid Incompatible Filter Interface.  I'm already
trying to get rid of the gratuitously incompatible INN filter interface.
I'd love to see one common filter API, common to Cyclone/Diablo/INN/
NNTPRelay/etc.  If the Cyclone API is so lacking, maybe it is just time
to hammer out a new common API.  I'm sure some INN hackers here would
rise to the challenge.  I'm here to do the Diablo stuff.  The Sedores
could probably be teased into doing NNTPRelay.  And Highwind is usually
pretty cool.

... JG

Re: Diablo debugging problems...
#40677
Author: Joe Greco
Date: Fri, 08 Oct 1999 00:00
48 lines
3218 bytes
In news.software.nntp article <1rvh8i10op.fsf@haey.ifi.uio.no>, Kjetil Torgrim Homme <kjetilho@haey.ifi.uio.no> wrote:
:[Russ Allbery]
:
:>   Brad Knowles <brad@shub-internet.org> writes:
:>   
:>   > This is very close to the xwrite() routine that Joe posted, but
:>   > neither of these take into account the fact that you should only
:>   > go through this loop so many times before you drop out.  If you
:>   > don't have a method of giving up when things get hopelessly
:>   > slow, you can bog down the whole system waiting on a single
:>   > write() to complete.
:>   
:>   Well, to be fair, I've never seen that behavior from write(), so I
:>   think you may be worrying about an error condition that never
:>   happens in practice.  But it's a point, and it's theoretically
:>   possible I suppose.
:
:A loop with ENOSPC or EBADF (a bug elsewhere in the code) can happen.
:I think the correct approach is to retry if EAGAIN, and propagate
:other errors back to the caller.  It may also be useful to call
:abort() outright when you get an EBADF.  This means that the caller no
:longer needs to check for partial writes, but still have to handle
:errors like disk full[1].
:
:Kjetil T.
:
:[1] You can get a partial write in this case, but the code to handle
:disk full properly is usually complex anyhow.

I'd never seen a disk full error on a pipe, so the code I gave Brad didn't
even attempt to deal with it.  Again, I _only_ meant the code as a quick
way for Brad to verify whether or not it was a short write problem that was
getting him.  I wrote the code I meant it to be integrated into, and deemed
it sufficient for providing the information I wanted to know.

Now, in the case of a generic news system, yes, you could handle disk full
and situations like that in a variety of ways.  I believe Diablo does so by
truncating the file back to where it was (safe under the Diablo storage
paradigm), but one could make a case for sitting in a loop like xwrite,
with a "if disk full then sleep(30)" in there, since Diablo clears disk
space asynchronously - and the current behaviour is actually a bit on the
exasperating side.  But I think we agree that this is really more of an
application level issue, and that any "wrapper" functions like these are
really not very useful bandaids.

... JG

Re: Diablo debugging problems...
#40681
Author: Kjetil Torgrim Homme
Date: Fri, 08 Oct 1999 00:00
30 lines
2202 bytes
[Russ Allbery]

>   Brad Knowles <brad@shub-internet.org> writes:
>   
>   > This is very close to the xwrite() routine that Joe posted, but
>   > neither of these take into account the fact that you should only
>   > go through this loop so many times before you drop out.  If you
>   > don't have a method of giving up when things get hopelessly
>   > slow, you can bog down the whole system waiting on a single
>   > write() to complete.
>   
>   Well, to be fair, I've never seen that behavior from write(), so I
>   think you may be worrying about an error condition that never
>   happens in practice.  But it's a point, and it's theoretically
>   possible I suppose.

A loop with ENOSPC or EBADF (a bug elsewhere in the code) can happen.
I think the correct approach is to retry if EAGAIN, and propagate
other errors back to the caller.  It may also be useful to call
abort() outright when you get an EBADF.  This means that the caller no
longer needs to check for partial writes, but still have to handle
errors like disk full[1].


Kjetil T.

[1] You can get a partial write in this case, but the code to handle
disk full properly is usually complex anyhow.

Re: Diablo debugging problems...
#40687
Author: Russ Allbery
Date: Fri, 08 Oct 1999 00:00
39 lines
2529 bytes
Joe Greco <jgreco@ns.sol.net> writes:

> Fantastic, another Stupid Incompatible Filter Interface.  I'm already
> trying to get rid of the gratuitously incompatible INN filter interface.

Joe, no offense intended, but it's hardly like someone implemented a
standard filter API and then INN broke with it.  More the other way
around, although it's pretty hard to do things the way INN does them in
other servers.

> I'd love to see one common filter API, common to Cyclone/Diablo/INN/
> NNTPRelay/etc.  If the Cyclone API is so lacking, maybe it is just time
> to hammer out a new common API.  I'm sure some INN hackers here would
> rise to the challenge.

It would surprise me if folks working on INN would be interested in
standardizing on a filter interface that's slower than what INN has
already, which is a real problem for every other filter interface that
I've seen proposed.

If you really want to do this, I'd recommend writing the code that gets
the article, parses it, and provides the parsed article to the filter,
write that in as optimized fashion as possible, and have that be server
dependent.  Then the filter API would look a lot like the one that INN
already provides, which is pretty close to ideal for the author of a
filter since they just get handed an already parsed article and don't have
to reproduce that work themselves in every separate filter that they
write.

INN could then embed the filter directly, Diablo could use a C program
that embedded or linked with the filter (you could write the common code
as a library and have filters link with it, for example, to support the C
filters that you want), a future threaded server could run the filter in
its own thread, etc.

-- 
Russ Allbery (rra@stanford.edu)         <URL:http://www.eyrie.org/~eagle/>

Re: Diablo debugging problems...
#40703
Author: Russ Allbery
Date: Fri, 08 Oct 1999 00:00
39 lines
2634 bytes
Andrew Gierth <andrew@erlenstar.demon.co.uk> writes:
>>>>>> "Russ" == Russ Allbery <rra@stanford.edu> writes:

>  Russ> Then the filter API would look a lot like the one that INN
>  Russ> already provides, which is pretty close to ideal for the author
>  Russ> of a filter

> Actually it sucks; having to recompile just to add a new header that INN
> didn't previously know about is a pain.

The interface to headers leaves a bit to be desired, yes.  To me, that's
an implementation aspect of the current interface rather than an intrinsic
property of the interface (namely, getting the headers as a hash); you
could certainly implement it as a tied hash with some preloaded values
that will fetch any other header you want on demand.

We could also just provide the raw headers as well as the raw body, which
would probably be a good idea.

(The other annoyance about the current header parsing code is that it
doesn't handle the case of duplicated headers.  That's a real defect.)

My point, though, is that when I'm writing a filter, I want access to the
active file if relevant, the history file, have the ability to retrieve
other articles if I want to (although you normally don't want to,
obviously, for speed reasons), and don't want unnecessary copying going on
to get the article to me.  I also don't want to be redoing work that INN
is already doing anyway.

My opinion is that the Highwind external filter interface is the *worst*
case for a filter interface; it's basically the barest and simplest
possible way of tying a filter into the server and you have very little in
the way of an interface to the rest of the news system.  I want the server
to do more work for me than that; writing filters should be *easy*.

-- 
Russ Allbery (rra@stanford.edu)         <URL:http://www.eyrie.org/~eagle/>

Re: Diablo debugging problems...
#40706
Author: greg andruk
Date: Sat, 09 Oct 1999 00:00
35 lines
2398 bytes
Russ Allbery <rra@stanford.edu> wrote:

> Two things that I personally use in filters and would miss badly:  Direct
> access to the server active file without having to take the performance
> hit of reading it in and parsing it myself,

The new OVgroupstats() function fixes this for the kinds of things a
filter will want to see. [If you want to do grepping or see what an
'=' group is aliased to you still need to crack open the file, but
this too can be done fast in a C extension, and offhand I can't think
of why a filter would want to do either.]

All the new OV* stuff and the once-again-rational dbz interface make
playing with the databases *much* easier than it was in INN 2.0
through 2.2.

> and the ability to add additional message IDs to the history file so
> that those messages will be refused.

The IPC to get these into innd is pretty cheap, especially compared
with the cost of the actual history add.

> And dealing with shared memory in Perl isn't something I'm really excited
> about doing.

Perl's built-in shm stuff is kind of goofy since it seems to force a
copy, but what about an extension using shm with the manipulations
you're already doing in PLartfilter()?

> Neither is having to redo the header parsing that INN already did.

Well, what innd needs in a parsed header really isn't ideal for
filtering anyway, so I'm not sure this is a big loss.

Re: Diablo debugging problems...
#40708
Author: Andrew Gierth
Date: Sat, 09 Oct 1999 00:00
12 lines
1589 bytes
>>>>> "Russ" == Russ Allbery <rra@stanford.edu> writes:

 Russ> But then, I've never liked shared memory.

Shared memory at least gives you control over what information you
expose.  Using threads is like putting your entire program into shared
memory; the problems are multiplied accordingly.

-- 
Andrew.

Re: Diablo debugging problems...
#40709
Author: Andrew Gierth
Date: Sat, 09 Oct 1999 00:00
19 lines
1734 bytes
>>>>> "Russ" == Russ Allbery <rra@stanford.edu> writes:

 Russ> Then the filter API would look a lot like the one that INN
 Russ> already provides, which is pretty close to ideal for the author
 Russ> of a filter

Actually it sucks; having to recompile just to add a new header that
INN didn't previously know about is a pain.

IMO, the right thing is actually _not_ to pre-parse the article at
all, but to pass it to the filter in one chunk, and if you want to do
header or body parsing, then do it from a module loaded by the filter
(which in the INN case can even be implemented inside INN if need be,
and in the non-INN case can be loaded as usual).

-- 
Andrew.

Re: Diablo debugging problems...
#40710
Author: greg andruk
Date: Sat, 09 Oct 1999 00:00
27 lines
1924 bytes
Russ Allbery <rra@stanford.edu> wrote:

> greg andruk <meowing@banet.net> writes:

>> The new OVgroupstats() function fixes this for the kinds of things a
>> filter will want to see

> Which would mean you'd have to open the overview from inside the filter,
> as opposed to just adding a callback for it....

It occurs to me that a transit box can maintain this cheaply; keep the
index up to date but skip the actual writing of NOV entries.  All we
really care about is whether the group is there and maybe its flag,
after all.

> INN would have to be reading the article into shared memory as well.
> Ugh.

Had to use malloc anyway; this would just be trading one chunk of
concentrated evil for another, no?

>  But then, I've never liked shared memory.

I gather you had a _really_ bad experience with it at some point.
What'd it (fail to) do?

Re: Diablo debugging problems...
#40715
Author: Russ Allbery
Date: Sat, 09 Oct 1999 00:00
44 lines
2827 bytes
Andrew Gierth <andrew@erlenstar.demon.co.uk> writes:
>>>>>> "Russ" == Russ Allbery <rra@stanford.edu> writes:

>  Russ> My opinion is that the Highwind external filter interface is
>  Russ> the *worst* case for a filter interface;

> Have you ever tried to embed Perl into a threaded program?

> So far I know only one person who has, and it's caused him _major_
> problems.

It shouldn't be a problem provided that you don't try to run multiple Perl
interpretors at a time.  One thread needs to be running the interpretor
and the rest of the threads need to keep their hands off.

Is that not your experience?  Was that person trying to thread the Perl
interpretor itself or use it from inside multiple threads?  I wouldn't
recommend that either.

> I have a filter interface (not currently used in any transit code, but
> used in other contexts) that is based on shared memory and pipes.  It
> allows for a certain degree of pipelining between the server and the
> filter, and it also allows for a common filter interface for both
> local-post type filters that might need to modify the headers, and
> transit filters which merely signal accept/reject(reason).

Two things that I personally use in filters and would miss badly:  Direct
access to the server active file without having to take the performance
hit of reading it in and parsing it myself, and the ability to add
additional message IDs to the history file so that those messages will be
refused.  The latter you can add the the API; the former would require
more shared memory.

Just being able to add more callbacks with ten-line XS functions and be
able to touch anything that INN touches is really rather appealing.

And dealing with shared memory in Perl isn't something I'm really excited
about doing.  Neither is having to redo the header parsing that INN
already did.

-- 
Russ Allbery (rra@stanford.edu)         <URL:http://www.eyrie.org/~eagle/>

Re: Diablo debugging problems...
#40716
Author: Andrew Gierth
Date: Sat, 09 Oct 1999 00:00
15 lines
1567 bytes
>>>>> "Russ" == Russ Allbery <rra@stanford.edu> writes:

 >> No.

 Russ> Hm.  I'll check with Perl embedding gurus on the topic, then.

And before you ask, yes we did build Perl with its own (non-thread-safe)
malloc disabled.

This was on Solaris 2.6, btw.

-- 
Andrew.

Page 1 of 2 • 57 total messages
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads