diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2003-08-11 21:23:59 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2003-08-11 21:23:59 +0000 |
commit | 3719d82b7f6fdabfa6a4b1f95efac55aa096dd52 (patch) | |
tree | c7f416a1d3a643caa035e8cf92b9d596df6d4f5c /usr.bin/ftp/ftp.c | |
parent | 19e51cb44f1ebcfd7a5da99a5f8da9addfdbba4f (diff) |
The empty() function basically effects a poll, so replace it with
real poll(). Gets rid of another static select(). OK deraadt@
Diffstat (limited to 'usr.bin/ftp/ftp.c')
-rw-r--r-- | usr.bin/ftp/ftp.c | 59 |
1 files changed, 24 insertions, 35 deletions
diff --git a/usr.bin/ftp/ftp.c b/usr.bin/ftp/ftp.c index 64b37928fad..dc83b52637b 100644 --- a/usr.bin/ftp/ftp.c +++ b/usr.bin/ftp/ftp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ftp.c,v 1.53 2003/06/03 02:56:08 millert Exp $ */ +/* $OpenBSD: ftp.c,v 1.54 2003/08/11 21:23:58 millert Exp $ */ /* $NetBSD: ftp.c,v 1.27 1997/08/18 10:20:23 lukem Exp $ */ /* @@ -63,7 +63,7 @@ #if 0 static char sccsid[] = "@(#)ftp.c 8.6 (Berkeley) 10/27/94"; #else -static char rcsid[] = "$OpenBSD: ftp.c,v 1.53 2003/06/03 02:56:08 millert Exp $"; +static char rcsid[] = "$OpenBSD: ftp.c,v 1.54 2003/08/11 21:23:58 millert Exp $"; #endif #endif /* not lint */ @@ -82,12 +82,13 @@ static char rcsid[] = "$OpenBSD: ftp.c,v 1.53 2003/06/03 02:56:08 millert Exp $" #include <err.h> #include <errno.h> #include <netdb.h> +#include <poll.h> +#include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <utime.h> -#include <stdarg.h> #include "ftp_var.h" @@ -449,18 +450,6 @@ getreply(expecteof) } } -int -empty(mask, sec) - fd_set *mask; - int sec; -{ - struct timeval t; - - t.tv_sec = (long) sec; - t.tv_usec = 0; - return (select(32, mask, (fd_set *) 0, (fd_set *) 0, &t)); -} - jmp_buf sendabort; void @@ -1697,7 +1686,7 @@ proxtrans(cmd, local, remote) int prox_type, nfnd; volatile int secndflag; char * volatile cmd2; - fd_set mask; + struct pollfd pfd[1]; oldintr = NULL; secndflag = 0; @@ -1791,12 +1780,11 @@ abort: abort_remote(NULL); pswitch(!proxy); if (cpend) { - FD_ZERO(&mask); - FD_SET(fileno(cin), &mask); - if ((nfnd = empty(&mask, 10)) <= 0) { - if (nfnd < 0) { + pfd[0].fd = fileno(cin); + pfd[0].events = POLLIN; + if ((nfnd = poll(pfd, 1, 10 * 1000)) <= 0) { + if (nfnd < 0) warn("abort"); - } if (ptabflg) code = -1; lostpeer(); @@ -1817,18 +1805,17 @@ reset(argc, argv) int argc; char *argv[]; { - fd_set mask; + struct pollfd pfd[1]; int nfnd = 1; - FD_ZERO(&mask); + pfd[0].fd = fileno(cin); + pfd[0].events = POLLIN; while (nfnd > 0) { - FD_SET(fileno(cin), &mask); - if ((nfnd = empty(&mask, 0)) < 0) { + if ((nfnd = poll(pfd, 1, 0)) < 0) { warn("reset"); code = -1; lostpeer(); - } - else if (nfnd) { + } else if (nfnd) { (void)getreply(0); } } @@ -1886,7 +1873,7 @@ abort_remote(din) { char buf[BUFSIZ]; int nfnd; - fd_set mask; + struct pollfd pfd[2]; if (cout == NULL) { warnx("Lost control connection for abort."); @@ -1905,20 +1892,22 @@ abort_remote(din) warn("abort"); fprintf(cout, "%cABOR\r\n", DM); (void)fflush(cout); - FD_ZERO(&mask); - FD_SET(fileno(cin), &mask); + pfd[0].fd = fileno(cin); + pfd[0].events = POLLIN; + nfnd = 1; if (din) { - FD_SET(fileno(din), &mask); + pfd[1].fd = fileno(din); + pfd[1].events = POLLIN; + nfnd++; } - if ((nfnd = empty(&mask, 10)) <= 0) { - if (nfnd < 0) { + if ((nfnd = poll(pfd, nfnd, 10 * 1000)) <= 0) { + if (nfnd < 0) warn("abort"); - } if (ptabflg) code = -1; lostpeer(); } - if (din && FD_ISSET(fileno(din), &mask)) { + if (din && (pfd[1].revents & POLLIN)) { while (read(fileno(din), buf, BUFSIZ) > 0) /* LOOP */; } |