[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [leafnode-list] Error Message
On Tue, Jul 18, 2000 at 03:58:44PM -0500, Mike Castle wrote:
> On Tue, Jul 18, 2000 at 10:14:07PM +0200, Cornelius Krasel wrote:
> > problem. More interestingly, I got at least one answer. It says,
> > basically, that the fgets() for some reason put a \0 byte into the
> > string (or nothing at all) and did not return NULL. This explains
> > that the length of the "string" is 0. The guy further asks for the
> > output of strace(), ferror() and feof(). I hereby relay this question
> > to you :-)
>
> Will do. I'll try to throw in some pertinent output statements and see
> what falls out.
Well, this is interesting.....
>From fetchnews:
Tue Jul 18 20:13:14 2000
len=0
feof()=0
ferror=0
buf==
Tue Jul 18 20:13:14 2000
len=0
feof()=0
ferror=0
buf==
>From strace -s 8192 -t:
20:13:13 write(4, "HEAD 90838\r\n", 12) = 12
20:13:13 read(5, "221 90838 <X> article retrieved - head follows\r\n
Path: P\r\nFrom: a@xxxxx\r\n
Newsgroups: N\r\n
Subject: S\r\n
Lines: 22\r\n
Message-ID: <X>\r\n
Date: D\r\n
NNTP-Posting-Host: H\r\n
NNTP-Posting-Date: D\r\n
Xref: ZZZZ N:90838\r\n
.\r\n", 1024) = 595
20:13:13 stat("/var/spool/news/message.id/885/<X>", 0xbffffb3c) = -1 ENOENT (No such file or directory)
20:13:13 open("/var/spool/news/message.id/885/<X>", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 8
20:13:13 fstat(8, {st_mode=S_IFREG|0664, st_size=0, ...}) = 0
20:13:13 old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40133000
20:13:13 link("/var/spool/news/message.id/885/<X>", "11063") = 0
20:13:13 write(4, "BODY 90838\r\n", 12) = 12
bunch of \0\0\0 in the following line
20:13:13 read(5, "222 90838 <X> article retrieved - body follows\r\n
\r\n
[deleted]\r\n
end\r\n
\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\r\n
\r\n
.\r\n", 1024) = 927
20:13:14 time(NULL) = 963969194
20:13:14 write(2, "Tue Jul 18 20:13:14 2000\n
len=0\n
feof()=0\n
ferror=0\n
buf==\n", 55) = 55
20:13:14 write(8, "Path: P\n
Message-ID: <X>\n
From: a@xxxxx\n
Newsgroups: N\n
Subject: S\n
Date: D\n
Lines: 22\n
NNTP-Posting-Host: H\n
NNTP-Posting-Date: D\n
Xref: thune.mrc-home.org N:11063\n
\n
\n
[deleted]\n
end\n
\n", 1298) = 1298
20:13:14 close(8) = 0
20:13:14 munmap(0x40133000, 4096) = 0
Now, fortunately, fgets() does soemthing somewhat surprising. It returns a
single empty string of length 0 for the run of binary zeros, then returns the
blank line then the "." line.
Net result is, leafnode actually saves to disk a cleaner post!
What we are seeing is that when the nulls get hit, fetchnews is bumping up
size, for no real reason. If you hit a group with a bunch of these bogus
posts, reallocs go through the roof!
What I suggest then, is the following patch:
========
diff -ru leafnode-1.9.14.orig/miscutil.c leafnode-1.9.14/miscutil.c
--- leafnode-1.9.14.orig/miscutil.c Mon May 22 12:31:49 2000
+++ leafnode-1.9.14/miscutil.c Tue Jul 18 22:14:56 2000
@@ -699,8 +699,10 @@
if (len > 0 && ( buf[len-1] == '\n' || len < size-1 ) )
break; /* the whole line has been read */
- size += size+100;
- buf = critrealloc(buf, size, "reading line" );
+ if ( len > 0 ) {
+ size += 100;
+ buf = critrealloc(buf, size, "reading line" );
+ }
}
if ( len == 0 )
========
mrc
--
Mike Castle Life is like a clock: You can work constantly
dalgoda@xxxxxxxxxxxxx and be right all the time, or not work at all
www.netcom.com/~dalgoda/ and be right at least twice a day. -- mrc
We are all of us living in the shadow of Manhattan. -- Watchmen
--
leafnode-list@xxxxxxxxxxxxxxxxxxxxxxxxxxxx -- mailing list for leafnode
To unsubscribe, send mail with "unsubscribe" in the subject to the list