summaryrefslogtreecommitdiffstats
path: root/hunt/hunt
diff options
context:
space:
mode:
authormycroft <mycroft@NetBSD.org>2002-09-20 15:47:19 +0000
committermycroft <mycroft@NetBSD.org>2002-09-20 15:47:19 +0000
commit5395af2c00ffe8b4a251932ea65bec2b4b185d8c (patch)
tree76c4f36faff9f69f5c65924a3bd6d49de765b6c1 /hunt/hunt
parentfbbd6c7c128dbf421371478eeab8fd37a03208d9 (diff)
downloadbsdgames-darwin-5395af2c00ffe8b4a251932ea65bec2b4b185d8c.tar.gz
bsdgames-darwin-5395af2c00ffe8b4a251932ea65bec2b4b185d8c.tar.zst
bsdgames-darwin-5395af2c00ffe8b4a251932ea65bec2b4b185d8c.zip
select() -> poll()
Diffstat (limited to 'hunt/hunt')
-rw-r--r--hunt/hunt/hunt.c20
-rw-r--r--hunt/hunt/playit.c26
2 files changed, 21 insertions, 25 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 */
}
diff --git a/hunt/hunt/playit.c b/hunt/hunt/playit.c
index 53fd6b34..381ef130 100644
--- a/hunt/hunt/playit.c
+++ b/hunt/hunt/playit.c
@@ -1,4 +1,4 @@
-/* $NetBSD: playit.c,v 1.4 1997/10/20 00:37:15 lukem Exp $ */
+/* $NetBSD: playit.c,v 1.5 2002/09/20 15:47:19 mycroft Exp $ */
/*
* Hunt
* Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold
@@ -7,10 +7,11 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: playit.c,v 1.4 1997/10/20 00:37:15 lukem Exp $");
+__RCSID("$NetBSD: playit.c,v 1.5 2002/09/20 15:47:19 mycroft Exp $");
#endif /* not lint */
# include <sys/file.h>
+# include <sys/poll.h>
# include <err.h>
# include <errno.h>
# include <curses.h>
@@ -217,26 +218,23 @@ out:
static unsigned char
getchr()
{
- fd_set readfds, s_readfds;
- int nfds, s_nfds;
+ struct pollfd set[2];
+ int nfds;
- FD_ZERO(&s_readfds);
- FD_SET(Socket, &s_readfds);
- FD_SET(STDIN, &s_readfds);
- s_nfds = (Socket > STDIN) ? Socket : STDIN;
- s_nfds++;
+ set[0].fd = Socket;
+ set[0].events = POLLIN;
+ set[1].fd = STDIN;
+ set[1].events = POLLIN;
one_more_time:
do {
errno = 0;
- readfds = s_readfds;
- nfds = s_nfds;
- nfds = select(nfds, &readfds, NULL, NULL, NULL);
+ nfds = poll(set, 2, INFTIM);
} while (nfds <= 0 && errno == EINTR);
- if (FD_ISSET(STDIN, &readfds))
+ if (set[1].revents && POLLIN)
send_stuff();
- if (! FD_ISSET(Socket, &readfds))
+ if (! (set[0].revents & POLLIN))
goto one_more_time;
icnt = read(Socket, ibuf, sizeof ibuf);
if (icnt < 0) {