X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fio%2Fpoll.c;h=cddc3cacd266e5b80392d91af367d689da093bd6;hp=b1a28fdb3f6dbb866b449ac77ddd00cae46d8463;hb=aae40e493625a07f4ac95476664447546b28661a;hpb=3022d16de40870c66c891a4aa75280e194ddf89f 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);