Subject: [984] Re: [772] hanging ftpds fix for wu-ftpd 2.4

From: [email-masked] (Chris Ho (8292))
Date: Tue, 27 Dec 1994 21:34:19 -0500

When I try to rebuild ftpd with the following patch on my Sun Sparc2 workstation, I got these error messages, does anyone has any idea what have I done wrong ?

Making ftpd.
gcc -g -DDEBUG -I.. -I../support -L../support -target sun4 -c ftpd.c
ftpd.c: In function `dataconn':
ftpd.c:1711: storage size of `timeout' isn't known
*** Error code 1
make: Fatal error: Command failed for target 'ftpd.o'

Thank you in advance.

..Chris Ho

> 
> 
> The following patch works around a problem with wu-ftpd.
> Recently we've seen an increasing number of ftpd's sticking around.
> 
> This scenario has become increasingly common since netscape was released
> and from our logs it does look like web-browser connections caused this
> problem.
> 
> After some investigation it turned out that ftpd hung in accept.
> (thanks to lsof and truss).  
> 
> Problem scenario:
> 
> 	client sends "PASV"
> 	client sends "RETR file"
> 	client doesn't open a connection, instead the client aborts.
> 
> 
> This fix may not be portable, but works for me on Solaris 2.x and probably
> works on SunOS 4.1.x and BSD derivatives with fd_set typedef'ed as well.
> Some systes may need to include extra files.
> 
> The fix is a timeout on accept with select().  The timeout is set to 120
> seconds, but I have no idea whether that is sufficient.
> 
> Please include me in any replies, as I'm not on this list.
> 
> Casper
> 
> *** ftpd.c.org	Thu Apr 14 22:05:35 1994
> --- ftpd.c	Mon Nov 21 19:40:59 1994
> ***************
> *** 1710,1717 ****
> --- 1710,1731 ----
>           int s,
>             fromlen = sizeof(from);
>   
> + #ifdef FD_ZERO
> + 	struct timeval timeout;
> + 	fd_set set;
> + 
> + 	FD_ZERO(&set);
> + 	FD_SET(pdata, &set);
> + 
> + 	timeout.tv_usec = 0;
> + 	timeout.tv_sec = 120;
> + 
> + 	if (select(pdata+1, &set, (fd_set *) 0, (fd_set *) 0, &timeout) == 0 ||
> + 	    (s = accept(pdata, (struct sockaddr *) &from, &fromlen)) < 0) {
> + #else
>           s = accept(pdata, (struct sockaddr *) &from, &fromlen);
>           if (s < 0) {
> + #endif
>               reply(425, "Can't open data connection.");
>               (void) close(pdata);
>               pdata = -1;
>

---

From: Casper Dik <[email-masked]>
Date: Wed, 28 Dec 1994 14:21:44 +0100

>When I try to rebuild ftpd with the following patch on my Sun Sparc2 workstation, I got these erro
r messages, does anyone has any idea what have I done wrong ?
>make: Fatal error: Command failed for target 'ftpd.o'

This is on SunOS 4.1.x?  You'd probably need to include one more header,
the header that defines "struct timeval"".

Casper