[PATCH] tin hangs after network connection went down

Dennis Preiser <[email protected]> Thu, 17 Dec 2009 23:25:52 +0100
Newsgroups gmane.network.tin.devel
Message-ID <[email protected]>
Hello,

I encountered the following issue: after the network connection went  
down (i.e.: unplug the cable), tin hangs infinitely after trying to  
read the next article or enter a group (NNTP related actions). This  
happens because s_gets() in nntplib.c:get_server() blocks.

Attached a possible fix. It uses alarm() in get_server() to start  
(and stop) a timer and installs a signal handler for SIGALRM in  
signal.c which does a tin_done(NNTP_ERROR_EXIT). The "if 0'ed"  
NNTP_READ_TIMEOUT from nntplib.h is (re)used to define the timeout.

Open issue:
I'm not sure whether alarm() is available on all platforms. I guess  
alarm() is available when SIGALRM is defined, but I'm not sure.

Dennis
20091217.diff.gz (application/x-gzip, 1.1 KB) - not displayed