summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/mrouted/defs.h4
-rw-r--r--usr.sbin/mrouted/main.c36
-rw-r--r--usr.sbin/mrouted/rsrr.c4
3 files changed, 19 insertions, 25 deletions
diff --git a/usr.sbin/mrouted/defs.h b/usr.sbin/mrouted/defs.h
index af73fcd39de..4c9224a4237 100644
--- a/usr.sbin/mrouted/defs.h
+++ b/usr.sbin/mrouted/defs.h
@@ -37,7 +37,7 @@
#endif /* RSRR */
typedef void (*cfunc_t)(void *);
-typedef void (*ihfunc_t)(int, fd_set *);
+typedef void (*ihfunc_t)(int);
#include "dvmrp.h"
#include "vif.h"
@@ -280,7 +280,7 @@ extern int find_src_grp(u_int32_t src, u_int32_t mask,
/* rsrr.c */
extern void rsrr_init(void);
-extern void rsrr_read(int f, fd_set *rfd);
+extern void rsrr_read(int f);
extern void rsrr_clean(void);
extern void rsrr_cache_send(struct gtable *gt, int notify);
extern void rsrr_cache_clean(struct gtable *gt);
diff --git a/usr.sbin/mrouted/main.c b/usr.sbin/mrouted/main.c
index 161226d97be..e3afa0da040 100644
--- a/usr.sbin/mrouted/main.c
+++ b/usr.sbin/mrouted/main.c
@@ -22,6 +22,7 @@
#include "defs.h"
#include <stdarg.h>
#include <fcntl.h>
+#include <poll.h>
#include <util.h>
#include <err.h>
@@ -41,8 +42,8 @@ u_char pruning = 1; /* Enable pruning by default */
#define NHANDLERS 2
static struct ihandler {
- int fd; /* File descriptor */
- ihfunc_t func; /* Function to call with &fd_set */
+ int fd; /* File descriptor */
+ ihfunc_t func; /* Function to call */
} ihandlers[NHANDLERS];
static int nhandlers = 0;
@@ -79,9 +80,8 @@ main(int argc, char *argv[])
FILE *fp;
struct timeval tv;
u_int32_t prev_genid;
- int vers;
- fd_set rfds, readers;
- int nfds, n, i, ch;
+ struct pollfd *pfd;
+ int vers, n, i, ch;
sigset_t mask, omask;
const char *errstr;
@@ -237,17 +237,12 @@ usage: fprintf(stderr,
if (debug != 0)
(void)signal(SIGQUIT, dump);
- FD_ZERO(&readers);
- if (igmp_socket >= FD_SETSIZE)
- logit(LOG_ERR, 0, "descriptor too big");
- FD_SET(igmp_socket, &readers);
- nfds = igmp_socket + 1;
+ pfd = calloc(sizeof(struct pollfd), 1 + nhandlers);
+ pfd[0].fd = igmp_socket;
+ pfd[0].events = POLLIN;
for (i = 0; i < nhandlers; i++) {
- if (ihandlers[i].fd >= FD_SETSIZE)
- logit(LOG_ERR, 0, "descriptor too big");
- FD_SET(ihandlers[i].fd, &readers);
- if (ihandlers[i].fd >= nfds)
- nfds = ihandlers[i].fd + 1;
+ pfd[i + 1].fd = ihandlers[i].fd;
+ pfd[i + 1].events = POLLIN;
}
/*
@@ -268,14 +263,13 @@ usage: fprintf(stderr,
*/
dummy = 0;
for(;;) {
- bcopy((char *)&readers, (char *)&rfds, sizeof(rfds));
- if ((n = select(nfds, &rfds, NULL, NULL, NULL)) < 0) {
+ if ((n = poll(pfd, nhandlers + 1, -1)) < 0) {
if (errno != EINTR) /* SIGALRM is expected */
- logit(LOG_WARNING, errno, "select failed");
+ logit(LOG_WARNING, errno, "poll failed");
continue;
}
- if (FD_ISSET(igmp_socket, &rfds)) {
+ if (pfd[0].revents & POLLIN) {
recvlen = recvfrom(igmp_socket, recv_buf, RECV_BUF_SIZE,
0, NULL, &dummy);
if (recvlen < 0) {
@@ -291,8 +285,8 @@ usage: fprintf(stderr,
}
for (i = 0; i < nhandlers; i++) {
- if (FD_ISSET(ihandlers[i].fd, &rfds)) {
- (*ihandlers[i].func)(ihandlers[i].fd, &rfds);
+ if (pfd[i + 1].revents & POLLIN) {
+ (*ihandlers[i].func)(ihandlers[i].fd);
}
}
}
diff --git a/usr.sbin/mrouted/rsrr.c b/usr.sbin/mrouted/rsrr.c
index 5e98d055d66..fa58b848984 100644
--- a/usr.sbin/mrouted/rsrr.c
+++ b/usr.sbin/mrouted/rsrr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rsrr.c,v 1.10 2004/08/01 18:32:19 deraadt Exp $ */
+/* $OpenBSD: rsrr.c,v 1.11 2013/04/21 00:24:42 deraadt Exp $ */
/* $NetBSD: rsrr.c,v 1.3 1995/12/10 10:07:14 mycroft Exp $ */
/*
@@ -113,7 +113,7 @@ rsrr_init(void)
/* Read a message from the RSRR socket */
void
-rsrr_read(int f, fd_set *rfd)
+rsrr_read(int f)
{
int rsrr_recvlen;
sigset_t mask, omask;