diff options
author | Jason Downs <downsj@cvs.openbsd.org> | 1999-04-29 21:38:44 +0000 |
---|---|---|
committer | Jason Downs <downsj@cvs.openbsd.org> | 1999-04-29 21:38:44 +0000 |
commit | 55f2df96942e22e55589ed9df34cbdfb75cfd2d5 (patch) | |
tree | 46abed2da1919fd4d4545810fad493c3085cb3fc | |
parent | 15b1c0df89fc6f80bed754445152e81224200700 (diff) |
Work around the blocking read() that causes so many hung ftpd processes.
This has been extensively tested.
-rw-r--r-- | libexec/ftpd/ftpd.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c index 67f69f787fa..d85b0c05473 100644 --- a/libexec/ftpd/ftpd.c +++ b/libexec/ftpd/ftpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ftpd.c,v 1.53 1999/02/26 00:15:54 art Exp $ */ +/* $OpenBSD: ftpd.c,v 1.54 1999/04/29 21:38:43 downsj Exp $ */ /* $NetBSD: ftpd.c,v 1.15 1995/06/03 22:46:47 mycroft Exp $ */ /* @@ -1388,11 +1388,19 @@ receive_data(instr, outstr) case TYPE_I: case TYPE_L: - while ((cnt = read(fileno(instr), buf, sizeof(buf))) > 0) { - if (write(fileno(outstr), buf, cnt) != cnt) - goto file_err; - byte_count += cnt; - } + signal (SIGALRM, lostconn); + + do { + (void) alarm ((unsigned) timeout); + cnt = read(fileno(instr), buf, sizeof(buf)); + (void) alarm (0); + + if (cnt > 0) { + if (write(fileno(outstr), buf, cnt) != cnt) + goto file_err; + byte_count += cnt; + } + } while (cnt > 0); if (cnt < 0) goto data_err; transflag = 0; |