chiark / gitweb /
event loop: remove now and tv_now from before/afterpoll API
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 11 Jun 2011 12:26:14 +0000 (13:26 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 26 Jun 2011 11:07:26 +0000 (12:07 +0100)
beforepoll/afterpoll routines now use the global variables provided.

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 ab94832caaa726aaac76c1d3d5ca03a2629d42b2..6f4b7380198e7ad37dbf367d36b43b39a704e979 100644 (file)
--- a/log.c
+++ b/log.c
@@ -488,8 +488,7 @@ struct fdlog {
 };
 
 static int log_from_fd_beforepoll(void *sst, struct pollfd *fds, int *nfds_io,
-                                 int *timeout_io,
-                                 const struct timeval *tv_now, uint64_t *now)
+                                 int *timeout_io)
 {
     struct fdlog *st=sst;
     if (!st->finished) {
@@ -500,8 +499,7 @@ static int log_from_fd_beforepoll(void *sst, struct pollfd *fds, int *nfds_io,
     return 0;
 }
 
-static void log_from_fd_afterpoll(void *sst, struct pollfd *fds, int nfds,
-                                 const struct timeval *tv_now, uint64_t *now)
+static void log_from_fd_afterpoll(void *sst, struct pollfd *fds, int nfds)
 {
     struct fdlog *st=sst;
     int r,remain,i;
index babcaaca74b72cf3369088c1df14e66b14da535f..968e93c3e92db76c92dcd2bcb67b2a2d5d8f8a26 100644 (file)
--- a/process.c
+++ b/process.c
@@ -176,8 +176,7 @@ int sys_cmd(const char *path, const char *arg, ...)
 
 static beforepoll_fn signal_beforepoll;
 static int signal_beforepoll(void *st, struct pollfd *fds, int *nfds_io,
-                            int *timeout_io, const struct timeval *tv_now,
-                            uint64_t *now)
+                            int *timeout_io)
 {
     if (*nfds_io<1) {
        *nfds_io=1;
@@ -190,8 +189,7 @@ static int signal_beforepoll(void *st, struct pollfd *fds, int *nfds_io,
 }
 
 static afterpoll_fn signal_afterpoll;
-static void signal_afterpoll(void *st, struct pollfd *fds, int nfds,
-                            const struct timeval *tv, uint64_t *now)
+static void signal_afterpoll(void *st, struct pollfd *fds, int nfds)
 {
     uint8_t buf[16];
     struct signotify *n;
index b7c56e3bdc4cd6ea87a16eae3636bde459e8cd35..f60b11282e0bbdc41ba5830414903a3ecb0a3479 100644 (file)
@@ -39,15 +39,13 @@ static bool_t resolve_request(void *sst, cstring_t name,
 }
 
 static int resolver_beforepoll(void *sst, struct pollfd *fds, int *nfds_io,
-                              int *timeout_io, const struct timeval *tv_now,
-                              uint64_t *now)
+                              int *timeout_io)
 {
     struct adns *st=sst;
     return adns_beforepoll(st->ast, fds, nfds_io, timeout_io, tv_now);
 }
 
-static void resolver_afterpoll(void *sst, struct pollfd *fds, int nfds,
-                              const struct timeval *tv_now, uint64_t *now)
+static void resolver_afterpoll(void *sst, struct pollfd *fds, int nfds)
 {
     struct adns *st=sst;
     adns_query aq;
index f56fac235089940704eacb8802a24e2728af1ba8..274d35a5bc9ff8a5b7860e9f29da1469e42e5a72 100644 (file)
--- a/secnet.c
+++ b/secnet.c
@@ -269,7 +269,7 @@ static void run(void)
                   ((uint64_t)tv_now_global.tv_usec/(uint64_t)1000);
        idx=0;
        for (i=reg; i; i=i->next) {
-           i->after(i->state, fds+idx, i->nfds, &tv_now_global, &now_global);
+           i->after(i->state, fds+idx, i->nfds);
            idx+=i->nfds;
        }
        remain=total_nfds;
@@ -277,7 +277,7 @@ static void run(void)
        timeout=-1;
        for (i=reg; i; i=i->next) {
            nfds=remain;
-           rv=i->before(i->state, fds+idx, &nfds, &timeout, &tv_now_global, &now_global);
+           rv=i->before(i->state, fds+idx, &nfds, &timeout);
            if (rv!=0) {
                /* XXX we need to handle this properly: increase the
                   nfds available */
index 2439f148bdc39944beb15f2ddc15de75927fcbdd..9cc22059ad0272e189a4b54d3b5a505d67b7e71f 100644 (file)
--- a/secnet.h
+++ b/secnet.h
@@ -161,15 +161,12 @@ static const struct timeval *const tv_now = &tv_now_global;
 
 /***** SCHEDULING support */
 
-/* "now" is current program time, in milliseconds. It is derived
-   (once) from tv_now. If nfds_io is insufficient for your needs, set
-   it to the required number and return ERANGE. timeout is in milliseconds;
-   if it is too high then lower it. It starts at -1 (==infinite) */
+/* If nfds_io is insufficient for your needs, set it to the required
+   number and return ERANGE. timeout is in milliseconds; if it is too
+   high then lower it. It starts at -1 (==infinite) */
 typedef int beforepoll_fn(void *st, struct pollfd *fds, int *nfds_io,
-                         int *timeout_io, const struct timeval *tv_now,
-                         uint64_t *now);
-typedef void afterpoll_fn(void *st, struct pollfd *fds, int nfds,
-                         const struct timeval *tv_now, uint64_t *now);
+                         int *timeout_io);
+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
diff --git a/site.c b/site.c
index f3312db4e8e05f5c3b9e98e99dcf08f5c4b24099..b81f9104dbe1470eb5ceb59a8b162ff1c6fcda6a 100644 (file)
--- a/site.c
+++ b/site.c
@@ -945,8 +945,7 @@ static inline void site_settimeout(uint64_t timeout, uint64_t *now,
 }
 
 static int site_beforepoll(void *sst, struct pollfd *fds, int *nfds_io,
-                          int *timeout_io, const struct timeval *tv_now,
-                          uint64_t *now)
+                          int *timeout_io)
 {
     struct site *st=sst;
 
@@ -963,8 +962,7 @@ static int site_beforepoll(void *sst, struct pollfd *fds, int *nfds_io,
 }
 
 /* NB site_afterpoll will be called before site_beforepoll is ever called */
-static void site_afterpoll(void *sst, struct pollfd *fds, int nfds,
-                          const struct timeval *tv_now, uint64_t *now)
+static void site_afterpoll(void *sst, struct pollfd *fds, int nfds)
 {
     struct site *st=sst;
 
diff --git a/slip.c b/slip.c
index dd2e7274fedff08b56c7ae307cf8dd154a6d5fd6..a296e420597ee9e1ae81ef1ea0b16492b25ee91c 100644 (file)
--- a/slip.c
+++ b/slip.c
@@ -132,8 +132,7 @@ struct userv {
 };
 
 static int userv_beforepoll(void *sst, struct pollfd *fds, int *nfds_io,
-                           int *timeout_io, const struct timeval *tv_now,
-                           uint64_t *now)
+                           int *timeout_io)
 {
     struct userv *st=sst;
 
@@ -149,8 +148,7 @@ static int userv_beforepoll(void *sst, struct pollfd *fds, int *nfds_io,
     return 0;
 }
 
-static void userv_afterpoll(void *sst, struct pollfd *fds, int nfds,
-                           const struct timeval *tv_now, uint64_t *now)
+static void userv_afterpoll(void *sst, struct pollfd *fds, int nfds)
 {
     struct userv *st=sst;
     uint8_t rxbuf[DEFAULT_BUFSIZE];
diff --git a/tun.c b/tun.c
index 80606232d76de4eddff92b15e1c4c7b05f3cdfbf..d899f0c6d006219573fc60ef6e3f43943e4ba032 100644 (file)
--- a/tun.c
+++ b/tun.c
@@ -95,8 +95,7 @@ static cstring_t tun_flavour_str(uint32_t flavour)
 }
 
 static int tun_beforepoll(void *sst, struct pollfd *fds, int *nfds_io,
-                         int *timeout_io, const struct timeval *tv_now,
-                         uint64_t *now)
+                         int *timeout_io)
 {
     struct tun *st=sst;
     *nfds_io=1;
@@ -105,8 +104,7 @@ static int tun_beforepoll(void *sst, struct pollfd *fds, int *nfds_io,
     return 0;
 }
 
-static void tun_afterpoll(void *sst, struct pollfd *fds, int nfds,
-                         const struct timeval *tv_now, uint64_t *now)
+static void tun_afterpoll(void *sst, struct pollfd *fds, int nfds)
 {
     struct tun *st=sst;
     int l;
diff --git a/udp.c b/udp.c
index f02a05ce4f8c712146a760c5405037e8d7522292..4883d537111e83547e35f2ef16e04e4da3bf7aea 100644 (file)
--- a/udp.c
+++ b/udp.c
@@ -47,8 +47,7 @@ struct udp {
 };
 
 static int udp_beforepoll(void *state, struct pollfd *fds, int *nfds_io,
-                         int *timeout_io, const struct timeval *tv,
-                         uint64_t *now)
+                         int *timeout_io)
 {
     struct udp *st=state;
     if (*nfds_io<1) {
@@ -61,8 +60,7 @@ static int udp_beforepoll(void *state, struct pollfd *fds, int *nfds_io,
     return 0;
 }
 
-static void udp_afterpoll(void *state, struct pollfd *fds, int nfds,
-                         const struct timeval *tv, uint64_t *now)
+static void udp_afterpoll(void *state, struct pollfd *fds, int nfds)
 {
     struct udp *st=state;
     struct sockaddr_in from;