X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fio%2Fpoll.c;h=cddc3cacd266e5b80392d91af367d689da093bd6;hb=8f116a81b39b55031212abb0be2ad088cbf9fd87;hp=b1a28fdb3f6dbb866b449ac77ddd00cae46d8463;hpb=36bfb66bdf74f4f3382cd00dae7b899e80e2cf1a;p=ccan diff --git a/ccan/io/poll.c b/ccan/io/poll.c index b1a28fdb..cddc3cac 100644 --- a/ccan/io/poll.c +++ b/ccan/io/poll.c @@ -16,6 +16,14 @@ static struct pollfd *pollfds = NULL; static struct fd **fds = NULL; static LIST_HEAD(closing); static LIST_HEAD(always); +static struct timeabs (*nowfn)(void) = time_now; + +struct timeabs (*io_time_override(struct timeabs (*now)(void)))(void) +{ + struct timeabs (*old)(void) = nowfn; + nowfn = now; + return old; +} static bool add_fd(struct fd *fd, short events) { @@ -256,7 +264,7 @@ void *io_loop(struct timers *timers, struct timer **expired) if (timers) { struct timeabs now, first; - now = time_now(); + now = nowfn(); /* Call functions for expired timers. */ *expired = timers_expire(timers, now);