diff options
author | 2002-09-20 15:47:19 +0000 | |
---|---|---|
committer | 2002-09-20 15:47:19 +0000 | |
commit | 5395af2c00ffe8b4a251932ea65bec2b4b185d8c (patch) | |
tree | 76c4f36faff9f69f5c65924a3bd6d49de765b6c1 /hunt/hunt/hunt.c | |
parent | fbbd6c7c128dbf421371478eeab8fd37a03208d9 (diff) | |
download | bsdgames-darwin-5395af2c00ffe8b4a251932ea65bec2b4b185d8c.tar.gz bsdgames-darwin-5395af2c00ffe8b4a251932ea65bec2b4b185d8c.tar.zst bsdgames-darwin-5395af2c00ffe8b4a251932ea65bec2b4b185d8c.zip |
select() -> poll()
Diffstat (limited to 'hunt/hunt/hunt.c')
-rw-r--r-- | hunt/hunt/hunt.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/hunt/hunt/hunt.c b/hunt/hunt/hunt.c index 000755c8..9034b27f 100644 --- a/hunt/hunt/hunt.c +++ b/hunt/hunt/hunt.c @@ -1,4 +1,4 @@ -/* $NetBSD: hunt.c,v 1.12 2001/02/05 00:40:45 christos Exp $ */ +/* $NetBSD: hunt.c,v 1.13 2002/09/20 15:47:19 mycroft Exp $ */ /* * Hunt * Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold @@ -7,12 +7,13 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: hunt.c,v 1.12 2001/02/05 00:40:45 christos Exp $"); +__RCSID("$NetBSD: hunt.c,v 1.13 2002/09/20 15:47:19 mycroft Exp $"); #endif /* not lint */ # include <sys/param.h> # include <sys/stat.h> # include <sys/time.h> +# include <sys/poll.h> # include <ctype.h> # include <err.h> # include <errno.h> @@ -398,8 +399,7 @@ list_drivers() static SOCKET *listv; static unsigned int listmax; unsigned int listc; - fd_set mask; - struct timeval wait; + struct pollfd set[1]; if (initial) { /* do one time initialization */ # ifndef BROADCAST @@ -497,8 +497,8 @@ list_drivers() get_response: namelen = DAEMON_SIZE; errno = 0; - wait.tv_sec = 1; - wait.tv_usec = 0; + set[0].fd = test_socket; + set[0].events = POLLIN; for (;;) { if (listc + 1 >= listmax) { listmax += 20; @@ -506,9 +506,7 @@ get_response: listmax * sizeof(SOCKET)); } - FD_ZERO(&mask); - FD_SET(test_socket, &mask); - if (select(test_socket + 1, &mask, NULL, NULL, &wait) == 1 && + if (poll(set, 1, 1000) == 1 && recvfrom(test_socket, (char *) &port_num, sizeof(port_num), 0, (struct sockaddr *) &listv[listc], &namelen) > 0) { /* @@ -526,8 +524,8 @@ get_response: } if (errno != 0 && errno != EINTR) { - warn("select/recvfrom"); - leave(1, "select/recvfrom"); + warn("poll/recvfrom"); + leave(1, "poll/recvfrom"); /* NOTREACHED */ } |