diff options
author | Guido van Rooij <guido@FreeBSD.org> | 1995-11-29 19:52:30 +0000 |
---|---|---|
committer | Guido van Rooij <guido@FreeBSD.org> | 1995-11-29 19:52:30 +0000 |
commit | d6ed3c374d726d7cab768614f28201b28e9d2379 (patch) | |
tree | d514f7b5e6ea488d1d2c07f2e60b666a36427981 /libexec/ftpd/ftpd.c | |
parent | 8e050b2e86586bc87b4c209535c03d69919a1d31 (diff) | |
download | src-d6ed3c374d726d7cab768614f28201b28e9d2379.tar.gz src-d6ed3c374d726d7cab768614f28201b28e9d2379.zip |
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
Notes
Notes:
svn path=/head/; revision=12532
Diffstat (limited to 'libexec/ftpd/ftpd.c')
-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 832f175dffad..0e256bfd0f08 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; |