🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #42256

Re: Nasty little bug in Diablo dnewslink

#42256
From: Nickolai Zeldovich
Date: Thu, 16 Dec 1999 00:00
51 lines
2449 bytes
In article <3846828f$0$18507@news.zetnet.co.uk>, Paul Martin wrote:
>If dnewslink attempts to connect to a remote server, gets through the TCP
>handshake, but gets no greeting from the far server, it sits there, doing
>nothing, for ever.

After being bitten by this as well, I looked some more at the source and
it seems that KillFd isn't being set yet when reading the initial server
reply, so when dnewslink gets SIGALRM due to a timeout, it doesn't have
an fd to close. The following patch to dnewslink.c fixed this particular
bug for me; I'll probably submit it to Matt Dillon sometime soon along
with some other additions..


*** dnewslink.c	1999/12/15 06:42:29	1.3
--- dnewslink.c	1999/12/16 06:48:59	1.4
***************
*** 1026,1031 ****
--- 1026,1036 ----
  	clearCommandBuffer();
  	cfd = fd;
  
+ 	/* Set KillFd here to avoid deadlock when the remote server fails
+ 	 * to respond after initial connection
+ 	 */
+ 	KillFd = cfd;
+ 
  	switch(commandResponse(cfd, &ptr, NULL)) {
  	case OK_CANPOST:	/* innd	*/
  	case OK_NOPOST:		/* nntpd may still allow news transfers */
***************
*** 1034,1039 ****
--- 1039,1045 ----
  	    dl_logit("connect: %s\n", (ptr ? ptr : "(unknown error)"));
  	    stprintf("%s %s connect: err resp", HostName, CurrentBatchFile + CBFIndex);
  	    clearCommandBuffer();
+ 	    KillFd = -1;
  	    close(cfd);
  	    cfd = -1;
  	    fd = -1;
***************
*** 1079,1084 ****
--- 1085,1091 ----
  		dl_logit("mode headfeed failed: %s\n", (ptr ? ptr : "<Unexpected EOF>"));
  		stprintf("%s %s connect: mode headfeed failed", HostName, CurrentBatchFile + CBFIndex);
  		clearCommandBuffer();
+ 		KillFd = -1;
  		close(cfd);
  		cfd = -1;
  		sprintf(LastErrBuf, "mode headfeed command failed");

Technical Details
Message-ID: <slrn85h393.bkd.kolya@pepsi.mit.edu>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
References: <3846828f$0$18507@news.zetnet.co.uk>

Show Full Headers
Complete Article Headers
Message-ID: <slrn85h393.bkd.kolya@pepsi.mit.edu>
Subject: Re: Nasty little bug in Diablo dnewslink
Date: Thu, 16 Dec 1999 00:00:00 +0000
From: kolya@mit.edu (Nickolai Zeldovich)
References: <3846828f$0$18507@news.zetnet.co.uk>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
X-Deja-AN: 561310643
X-Trace: dreaderd 945327395 22867 18.239.2.240
Organization: Massachvsetts Institvte of Technology
User-Agent: slrn/0.9.5.7 (UNIX)
Newsgroups: news.software.nntp