summaryrefslogtreecommitdiffstats
path: root/usr.sbin/rtadvd
diff options
context:
space:
mode:
authorume <ume@FreeBSD.org>2003-08-14 18:43:57 +0000
committerume <ume@FreeBSD.org>2003-08-14 18:43:57 +0000
commit31525675904b199e80556db53c70d0777975e999 (patch)
treef0047c80e0712956d1faa24f21d8878c4ddeeac7 /usr.sbin/rtadvd
parent992b2cf29d70f08a3f00b6c610cb42aaf4545991 (diff)
downloadFreeBSD-src-31525675904b199e80556db53c70d0777975e999.zip
FreeBSD-src-31525675904b199e80556db53c70d0777975e999.tar.gz
support poll(2).
Obtained from: KAME MFC after: 1 week
Diffstat (limited to 'usr.sbin/rtadvd')
-rw-r--r--usr.sbin/rtadvd/Makefile2
-rw-r--r--usr.sbin/rtadvd/rtadvd.c37
2 files changed, 37 insertions, 2 deletions
diff --git a/usr.sbin/rtadvd/Makefile b/usr.sbin/rtadvd/Makefile
index 99a668d..179ba4e 100644
--- a/usr.sbin/rtadvd/Makefile
+++ b/usr.sbin/rtadvd/Makefile
@@ -18,7 +18,7 @@ PROG= rtadvd
MAN= rtadvd.conf.5 rtadvd.8
SRCS= rtadvd.c rrenum.c advcap.c if.c config.c timer.c dump.c
-CFLAGS+= -DINET6
+CFLAGS+= -DINET6 -DHAVE_POLL_H
DPADD= ${LIBCOMPAT}
LDADD= -lcompat
diff --git a/usr.sbin/rtadvd/rtadvd.c b/usr.sbin/rtadvd/rtadvd.c
index cecda2b..b4746c6 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 */
OpenPOWER on IntegriCloud