X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fio%2Fpoll.c;h=2fd39f6b1609d894ccd4c1a4127b74b87c8265aa;hb=b377324e5c1ad356b535f4c3724251c626abdf40;hp=e3f595c9884c0d2fcea42d598ca3321d067069a8;hpb=710d42d071a10093077d30d6e521f9599a9bc997;p=ccan diff --git a/ccan/io/poll.c b/ccan/io/poll.c index e3f595c9..2fd39f6b 100644 --- a/ccan/io/poll.c +++ b/ccan/io/poll.c @@ -167,6 +167,34 @@ void backend_plan_changed(struct io_conn *conn) some_always = true; } +void backend_wait_changed(const void *wait) +{ + unsigned int i; + + for (i = 0; i < num_fds; i++) { + struct io_conn *c, *duplex; + + /* Ignore listeners */ + if (fds[i]->listener) + continue; + c = (void *)fds[i]; + for (duplex = c->duplex; c; c = duplex, duplex = NULL) { + /* Ignore closing. */ + if (!c->plan.next) + continue; + /* Not idle? */ + if (c->plan.io) + continue; + /* Waiting on something else? */ + if (c->plan.u1.const_vp != wait) + continue; + /* Make it do the next thing. */ + c->plan = io_always_(c->plan.next, c->plan.next_arg); + backend_plan_changed(c); + } + } +} + bool add_conn(struct io_conn *c) { if (!add_fd(&c->fd, c->plan.pollflag & (POLLIN|POLLOUT))) @@ -257,12 +285,12 @@ static bool finish_conns(struct io_conn **ready) return false; } -void backend_add_timeout(struct io_conn *conn, struct timespec duration) +void backend_add_timeout(struct io_conn *conn, struct timerel duration) { if (!timeouts.base) timers_init(&timeouts, time_now()); timer_add(&timeouts, &conn->timeout->timer, - time_add(time_now(), duration)); + timeabs_add(time_now(), duration)); conn->timeout->conn = conn; } @@ -302,11 +330,11 @@ void *do_io_loop(struct io_conn **ready) while (!io_loop_return) { int i, r, timeout = INT_MAX; - struct timespec now; + struct timeabs now; bool some_timeouts = false; if (timeouts.base) { - struct timespec first; + struct timeabs first; struct list_head expired; struct io_timeout *t; @@ -325,7 +353,7 @@ void *do_io_loop(struct io_conn **ready) /* Now figure out how long to wait for the next one. */ if (timer_earliest(&timeouts, &first)) { - uint64_t f = time_to_msec(time_sub(first, now)); + uint64_t f = time_to_msec(time_between(first, now)); if (f < INT_MAX) timeout = f; }