aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/rtadvd/rtadvd.c
diff options
context:
space:
mode:
authorHajimu UMEMOTO <ume@FreeBSD.org>2003-08-14 18:43:57 +0000
committerHajimu UMEMOTO <ume@FreeBSD.org>2003-08-14 18:43:57 +0000
commit5c706347d55a92f19d568c9e23af775c9bb2e2c4 (patch)
treef0047c80e0712956d1faa24f21d8878c4ddeeac7 /usr.sbin/rtadvd/rtadvd.c
parent0b22953b4ca3ebe4a4d8dbe4b167d9360cf9b5d2 (diff)
downloadsrc-5c706347d55a92f19d568c9e23af775c9bb2e2c4.tar.gz
src-5c706347d55a92f19d568c9e23af775c9bb2e2c4.zip
support poll(2).
Obtained from: KAME MFC after: 1 week
Notes
Notes: svn path=/head/; revision=118916
Diffstat (limited to 'usr.sbin/rtadvd/rtadvd.c')
-rw-r--r--usr.sbin/rtadvd/rtadvd.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/usr.sbin/rtadvd/rtadvd.c b/usr.sbin/rtadvd/rtadvd.c
index cecda2bbd245..b4746c6843d6 100644
--- a/usr.sbin/rtadvd/rtadvd.c
+++ b/usr.sbin/rtadvd/rtadvd.c
@@ -55,6 +55,10 @@
#include <string.h>
#include <stdlib.h>
#include <syslog.h>
+#ifdef HAVE_POLL_H
+#include <poll.h>
+#endif
+
#include "rtadvd.h"
#include "rrenum.h"
#include "advcap.h"
@@ -145,9 +149,13 @@ main(argc, argv)
int argc;
char *argv[];
{
+#ifdef HAVE_POLL_H
+ struct pollfd set[2];
+#else
fd_set *fdsetp, *selectfdp;
int fdmasks;
int maxfd = 0;
+#endif
struct timeval *timeout;
int i, ch;
int fflag = 0;
@@ -236,6 +244,16 @@ main(argc, argv)
fclose(pidfp);
}
+#ifdef HAVE_POLL_H
+ set[0].fd = sock;
+ set[0].events = POLLIN;
+ if (sflag == 0) {
+ rtsock_open();
+ set[1].fd = rtsock;
+ set[1].events = POLLIN;
+ } else
+ set[1].fd = -1;
+#else
maxfd = sock;
if (sflag == 0) {
rtsock_open();
@@ -257,12 +275,15 @@ main(argc, argv)
FD_SET(sock, fdsetp);
if (rtsock >= 0)
FD_SET(rtsock, fdsetp);
+#endif
signal(SIGTERM, set_die);
signal(SIGUSR1, rtadvd_set_dump_file);
while (1) {
+#ifndef HAVE_POLL_H
memcpy(selectfdp, fdsetp, fdmasks); /* reinitialize */
+#endif
if (do_dump) { /* SIGUSR1 */
do_dump = 0;
@@ -289,8 +310,14 @@ main(argc, argv)
__func__);
}
+#ifdef HAVE_POLL_H
+ if ((i = poll(set, 2, timeout ? (timeout->tv_sec * 1000 +
+ timeout->tv_usec / 1000) : INFTIM)) < 0)
+#else
if ((i = select(maxfd + 1, selectfdp, NULL, NULL,
- timeout)) < 0) {
+ timeout)) < 0)
+#endif
+ {
/* EINTR would occur upon SIGUSR1 for status dump */
if (errno != EINTR)
syslog(LOG_ERR, "<%s> select: %s",
@@ -299,9 +326,17 @@ main(argc, argv)
}
if (i == 0) /* timeout */
continue;
+#ifdef HAVE_POLL_H
+ if (rtsock != -1 && set[1].revents & POLLIN)
+#else
if (rtsock != -1 && FD_ISSET(rtsock, selectfdp))
+#endif
rtmsg_input();
+#ifdef HAVE_POLL_H
+ if (set[0].revents & POLLIN)
+#else
if (FD_ISSET(sock, selectfdp))
+#endif
rtadvd_input();
}
exit(0); /* NOTREACHED */