chiark / gitweb /
poll: Abolish max_nfds
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 20 Sep 2014 17:16:09 +0000 (18:16 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 6 Oct 2014 22:10:23 +0000 (23:10 +0100)
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 <ijackson@chiark.greenend.org.uk>
log.c
process.c
resolver.c
secnet.c
secnet.h
site.c
slip.c
tun.c
udp.c

diff --git a/log.c b/log.c
index 95f01b6..6dbf25a 100644 (file)
--- 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);
 }
 
index 78d6536..0a718e2 100644 (file)
--- 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 */
index 2466245..a39e9fc 100644 (file)
@@ -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);
 }
index 6d08323..4520b3e 100644 (file)
--- 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(&reg, i, entry);
index e79352b..1e1e75c 100644 (file)
--- 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 (file)
--- 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 (file)
--- 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 (file)
--- 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 (file)
--- a/udp.c
+++ b/udp.c
@@ -326,7 +326,7 @@ static void udp_phase_hook(void *sst, uint32_t new_phase)
     for (i=0; i<st->n_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,