From: Ian Jackson Date: Sat, 20 Sep 2014 17:16:09 +0000 (+0100) Subject: poll: Abolish max_nfds X-Git-Tag: v0.4.0_beta2~94 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=secnet.git;a=commitdiff_plain;h=32fc582f43a9a3841d2782674e055113729c2814 poll: Abolish max_nfds We do not need to be advised of a static maximum, since we dynamically size the array now. Abolish the variable (which is unused) and change all the callers. No functional change. Signed-off-by: Ian Jackson --- diff --git a/log.c b/log.c index 95f01b6..6dbf25a 100644 --- a/log.c +++ b/log.c @@ -545,7 +545,7 @@ void log_from_fd(int fd, cstring_t prefix, struct log_if *log) st->i=0; st->finished=False; - register_for_poll(st,log_from_fd_beforepoll,log_from_fd_afterpoll,1, + register_for_poll(st,log_from_fd_beforepoll,log_from_fd_afterpoll, prefix); } diff --git a/process.c b/process.c index 78d6536..0a718e2 100644 --- a/process.c +++ b/process.c @@ -313,7 +313,7 @@ void start_signal_handling(void) fatal_perror("start_signal_handling: fcntl(O_NONBLOCK)"); } - register_for_poll(NULL,signal_beforepoll,signal_afterpoll,1,"signal"); + register_for_poll(NULL,signal_beforepoll,signal_afterpoll,"signal"); signal_handling=True; /* Register signal handlers for all the signals we're interested in */ diff --git a/resolver.c b/resolver.c index 2466245..a39e9fc 100644 --- a/resolver.c +++ b/resolver.c @@ -200,7 +200,7 @@ static list_t *adnsresolver_apply(closure_t *self, struct cloc loc, } register_for_poll(st, resolver_beforepoll, resolver_afterpoll, - ADNS_POLLFDS_RECOMMENDED+5,"resolver"); + "resolver"); return new_closure(&st->cl); } diff --git a/secnet.c b/secnet.c index 6d08323..4520b3e 100644 --- a/secnet.c +++ b/secnet.c @@ -39,7 +39,6 @@ struct poll_interest { beforepoll_fn *before; afterpoll_fn *after; void *state; - int32_t max_nfds; int32_t nfds; cstring_t desc; LIST_ENTRY(poll_interest) entry; @@ -227,7 +226,7 @@ static void setup(dict_t *config) } void register_for_poll(void *st, beforepoll_fn *before, - afterpoll_fn *after, int32_t max_nfds, cstring_t desc) + afterpoll_fn *after, cstring_t desc) { struct poll_interest *i; @@ -235,7 +234,6 @@ void register_for_poll(void *st, beforepoll_fn *before, i->before=before; i->after=after; i->state=st; - i->max_nfds=max_nfds; i->nfds=0; i->desc=desc; LIST_INSERT_HEAD(®, i, entry); diff --git a/secnet.h b/secnet.h index e79352b..1e1e75c 100644 --- a/secnet.h +++ b/secnet.h @@ -215,13 +215,9 @@ typedef void afterpoll_fn(void *st, struct pollfd *fds, int nfds); /* Register interest in the main loop of the program. Before a call to poll() your supplied beforepoll function will be called. After - the call to poll() the supplied afterpoll function will be called. - max_nfds is a _hint_ about the maximum number of struct pollfd - structures you may require - you can always ask for more in - *nfds_io. */ + the call to poll() the supplied afterpoll function will be called. */ extern void register_for_poll(void *st, beforepoll_fn *before, - afterpoll_fn *after, int32_t max_nfds, - cstring_t desc); + afterpoll_fn *after, cstring_t desc); /***** END of scheduling support */ diff --git a/site.c b/site.c index abbaa1e..3ac2372 100644 --- a/site.c +++ b/site.c @@ -2049,7 +2049,7 @@ static list_t *site_apply(closure_t *self, struct cloc loc, dict_t *context, /* We are interested in poll(), but only for timeouts. We don't have any fds of our own. */ - register_for_poll(st, site_beforepoll, site_afterpoll, 0, "site"); + register_for_poll(st, site_beforepoll, site_afterpoll, "site"); st->timeout=0; st->remote_capabilities=0; diff --git a/slip.c b/slip.c index 1a60f40..badbc5d 100644 --- a/slip.c +++ b/slip.c @@ -391,7 +391,7 @@ static void userv_phase_hook(void *sst, uint32_t newphase) if (newphase==PHASE_RUN) { userv_invoke_userv(st); /* Register for poll() */ - register_for_poll(st, userv_beforepoll, userv_afterpoll, 2, + register_for_poll(st, userv_beforepoll, userv_afterpoll, st->slip.nl.name); } if (newphase==PHASE_SHUTDOWN) { diff --git a/tun.c b/tun.c index 102a24c..6ecde61 100644 --- a/tun.c +++ b/tun.c @@ -441,7 +441,7 @@ static void tun_phase_hook(void *sst, uint32_t newphase) } /* Register for poll() */ - register_for_poll(st, tun_beforepoll, tun_afterpoll, 1, st->nl.name); + register_for_poll(st, tun_beforepoll, tun_afterpoll, st->nl.name); } static list_t *tun_create(closure_t *self, struct cloc loc, dict_t *context, diff --git a/udp.c b/udp.c index 98da30d..bb8d9ef 100644 --- a/udp.c +++ b/udp.c @@ -326,7 +326,7 @@ static void udp_phase_hook(void *sst, uint32_t new_phase) for (i=0; in_socks; i++) udp_make_socket(st,&st->socks[i]); - register_for_poll(st,udp_beforepoll,udp_afterpoll,MAX_SOCKETS,"udp"); + register_for_poll(st,udp_beforepoll,udp_afterpoll,"udp"); } static list_t *udp_apply(closure_t *self, struct cloc loc, dict_t *context,