[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [leafnode-list] various hangs with fetchnews



John Covici <covici@xxxxxxxxxxxxxx> writes:

> I have found various hangs with fetchnews using 2.0b8.
> 
> If the remote server connects, but doesn't respond to a command,
> fetchnews will sit there for at least several hours waiting.  I
> eventually killed the thing, but it was quite a while.

I also saw these. There is no trivial fix for this, because leafnode
currently uses <stdio.h> and fgets and the like all over the place,
these don't have timeout handling. 

The only proper fix I can see is to switch to an own buffering (or see
if Postfix' suits and is compatible in respects of licensing, which I
still haven't got around to do) that has timeout handling.

As a workaround, placing some alarms into the code may help.

NOTE to other hackers: select doesn't mix with getline() or fgets()
because of buffering, but would be the best timeout handler available.

> Also, I saw fetchnews trying to get an article for 4 hours, it looked
> like bytes were coming in, but the size of the file didn't change and

The file may have been using buffered I/O, thus, you'd only see chunks
if the buffer size (not sure how big it is in your libc implementation
by default). If, e. g., the buffer is 8192 and your network feeds 500
Bytes every other minute, you'd have to wait until 8500 Bytes have come
in until ls shows 8192 Bytes.

> Any way to get around these -- do you know what fetchnews is trying to
> do when this is happening?

You can compile fetchnews with debug flags, assuming gcc and gdb:

rm *.[o] 
make CFLAGS="-ggdb -pipe"
make install

And when it hangs, look up its PID with lsof or ps, run 

gdb /path/to/fetchnews 12345

where 12345 needs to be replaced by fetchnews' actual PID.

After GDB has attached, issue "backtrace" and you can see where you
stopped it. To continue running it in gdb, use "c", to detach gdb and
continue fetchnews alone, use "detach", then "quit".

-- 
Matthias Andree

-- 
leafnode-list@xxxxxxxxxxxxxxxxxxxxxxxxxxxx -- mailing list for leafnode
To unsubscribe, send mail with "unsubscribe" in the subject to the list