diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2013-04-20 20:11:42 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2013-04-20 20:11:42 +0000 |
commit | 2a95690a8118149f35aa3b571209b49bc4739406 (patch) | |
tree | 44cba4f2fa715549e7c536d8ca5d09861ef4c1e7 /usr.sbin/rbootd | |
parent | 59141da73f2ab5c6e00263f59c3dbc2ea741226b (diff) |
replace select with poll
ok miod
Diffstat (limited to 'usr.sbin/rbootd')
-rw-r--r-- | usr.sbin/rbootd/rbootd.c | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/usr.sbin/rbootd/rbootd.c b/usr.sbin/rbootd/rbootd.c index 5f3695d8aa6..c1751db1494 100644 --- a/usr.sbin/rbootd/rbootd.c +++ b/usr.sbin/rbootd/rbootd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rbootd.c,v 1.23 2009/10/27 23:59:54 deraadt Exp $ */ +/* $OpenBSD: rbootd.c,v 1.24 2013/04/20 20:11:41 deraadt Exp $ */ /* $NetBSD: rbootd.c,v 1.5 1995/10/06 05:12:17 thorpej Exp $ */ /* @@ -58,6 +58,7 @@ #include <unistd.h> #include <util.h> #include <pwd.h> +#include <poll.h> #include "defs.h" @@ -85,7 +86,7 @@ main(int argc, char *argv[]) int c, fd, maxfds; sigset_t hmask, omask; struct passwd *pw; - fd_set rset; + struct pollfd pfd[1]; closefrom(STDERR_FILENO + 1); @@ -204,12 +205,10 @@ main(int argc, char *argv[]) * Main loop: receive a packet, determine where it came from, * and if we service this host, call routine to handle request. */ - maxfds = fd + 1; - FD_ZERO(&rset); - FD_SET(fd, &rset); + pfd[0].fd = fd; + pfd[0].events = POLLIN; for (;;) { struct timeval timeout; - fd_set r; int nsel; /* @@ -228,27 +227,19 @@ main(int argc, char *argv[]) doreconfig = 0; } - r = rset; - - if (RmpConns == NULL) { /* timeout isnt necessary */ - nsel = select(maxfds, &r, NULL, NULL, NULL); - } else { - timeout.tv_sec = RMP_TIMEOUT; - timeout.tv_usec = 0; - nsel = select(maxfds, &r, NULL, NULL, &timeout); - } + nsel = poll(pfd, 1, RmpConns ? RMP_TIMEOUT * 100 : -1); if (nsel < 0) { if (errno == EINTR) continue; - syslog(LOG_ERR, "select: %m"); + syslog(LOG_ERR, "poll: %m"); DoExit(); } else if (nsel == 0) { /* timeout */ DoTimeout(); /* clear stale conns */ continue; } - if (FD_ISSET(fd, &r)) { + if (pfd[0].revents & POLLIN) { RMPCONN rconn; CLIENT *client; int doread = 1; |