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>
Thu, 2 Oct 2014 15:31:13 +0000 (16:31 +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 95f01b6898d0eec03bab58f18684fbf1c7d51c3f..6dbf25aa3492afba341a511ff7e29441a2894ce6 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 78d65364e75d61a8b98447a827b484c739f429a4..0a718e20b443e5827d59762602e162300b272df8 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 8109a27d565388888bef7912588fe97667b569e1..3a6ea20561714426a6e490d5b418be4acd7bcf71 100644 (file)
@@ -205,7 +205,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 7a9d3f009274176620f36f4b8cc5f807c7362278..56294dcba2a7858abe741549a36fddd5b280b8c6 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 3b2ca93ef19e818ca423503b4425c63c8624c735..5a40d6cb44c1b556e1094040bedc1c74c033ef05 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 d46e1002bdc8c9a8799c79783c92da1ea13450dd..abc54b17e29ce91960bfce2c5e5fb3f6c04d0e0e 100644 (file)
--- a/site.c
+++ b/site.c
@@ -2048,7 +2048,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 1a60f40f64490f89f3b6533a55116b3d93d50b7e..badbc5d0fe02b3ebacaaa43e0fc60817f716d526 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 102a24cabed62169b11a0f17cdc7f191fdb2e70f..6ecde61794a3e3ea2821f6ebe185003c6ea07b4c 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 fcce186613b4de0424f2e94aab500a446b641f7b..623ac7c148d9961271398371d2e0ed858a6ba45a 100644 (file)
--- a/udp.c
+++ b/udp.c
@@ -317,7 +317,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,