From 90a39563035b70196da9c5bdc7c17a63b64449b0 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 11 Jun 2011 13:26:14 +0100 Subject: [PATCH] event loop: remove now and tv_now from before/afterpoll API beforepoll/afterpoll routines now use the global variables provided. Signed-off-by: Ian Jackson --- log.c | 6 ++---- process.c | 6 ++---- resolver.c | 6 ++---- secnet.c | 4 ++-- secnet.h | 13 +++++-------- site.c | 6 ++---- slip.c | 6 ++---- tun.c | 6 ++---- udp.c | 6 ++---- 9 files changed, 21 insertions(+), 38 deletions(-) diff --git a/log.c b/log.c index ab94832..6f4b738 100644 --- 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; diff --git a/process.c b/process.c index babcaac..968e93c 100644 --- 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; diff --git a/resolver.c b/resolver.c index b7c56e3..f60b112 100644 --- a/resolver.c +++ b/resolver.c @@ -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; diff --git a/secnet.c b/secnet.c index f56fac2..274d35a 100644 --- 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 */ diff --git a/secnet.h b/secnet.h index 2439f14..9cc2205 100644 --- 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 f3312db..b81f910 100644 --- 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 dd2e727..a296e42 100644 --- 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 8060623..d899f0c 100644 --- 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 f02a05c..4883d53 100644 --- 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; -- 2.30.2