diff options
author | guido <guido@FreeBSD.org> | 1995-11-29 19:52:30 +0000 |
---|---|---|
committer | guido <guido@FreeBSD.org> | 1995-11-29 19:52:30 +0000 |
commit | 8476f980ecdc58fda564f3280af8a5f2003a5515 (patch) | |
tree | d514f7b5e6ea488d1d2c07f2e60b666a36427981 /libexec | |
parent | 14b76de283623cb6c147f8a427b11158aa381e2e (diff) | |
download | FreeBSD-src-8476f980ecdc58fda564f3280af8a5f2003a5515.zip FreeBSD-src-8476f980ecdc58fda564f3280af8a5f2003a5515.tar.gz |
Timeout when an expected accept does not happen after all.
This gets rids of dozens of hanging ftpd's because some broken
pc implementation `forgets' to open a passive connection.
Obtained from: Wietse Venema
Diffstat (limited to 'libexec')
-rw-r--r-- | libexec/ftpd/ftpd.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c index 832f175..0e256bf 100644 --- a/libexec/ftpd/ftpd.c +++ b/libexec/ftpd/ftpd.c @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ftpd.c,v 1.11 1995/08/05 19:12:05 pst Exp $ + * $Id: ftpd.c,v 1.12 1995/08/28 21:30:49 mpp Exp $ */ #ifndef lint @@ -922,9 +922,17 @@ dataconn(name, size, mode) if (pdata >= 0) { struct sockaddr_in from; int s, fromlen = sizeof(from); + struct timeval timeout; + fd_set set; - s = accept(pdata, (struct sockaddr *)&from, &fromlen); - if (s < 0) { + 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) { reply(425, "Can't open data connection."); (void) close(pdata); pdata = -1; |