@@ -1326,12 +1326,6 @@ static void afterpoll_internal(libxl__egc *egc, libxl__poller *poller,
fd_occurs(egc, efd, revents);
}
- if (afterpoll_check_fd(poller,fds,nfds, poller->wakeup_pipe[0],POLLIN)) {
- poller->pipe_nonempty = 0;
- int e = libxl__self_pipe_eatall(poller->wakeup_pipe[0]);
- if (e) LIBXL__EVENT_DISASTER(egc, "read wakeup", e, 0);
- }
-
for (;;) {
libxl__ev_time *etime = LIBXL_TAILQ_FIRST(&CTX->etimes);
if (!etime)
@@ -1346,6 +1340,12 @@ static void afterpoll_internal(libxl__egc *egc, libxl__poller *poller,
time_occurs(egc, etime, ERROR_TIMEDOUT);
}
+
+ if (afterpoll_check_fd(poller,fds,nfds, poller->wakeup_pipe[0],POLLIN)) {
+ poller->pipe_nonempty = 0;
+ int e = libxl__self_pipe_eatall(poller->wakeup_pipe[0]);
+ if (e) LIBXL__EVENT_DISASTER(egc, "read wakeup", e, 0);
+ }
}
void libxl_osevent_afterpoll(libxl_ctx *ctx, int nfds, const struct pollfd *fds,
If a timer event callback causes this poller to be woken (not very unlikely) we would go round the poll loop twice rather than once. Do the poller pipe emptying at the end; this is slightly more efficient because it can't cause any callbacks, so it happens after all the callbacks have been run. (This pipe-emptying has to happen in afterpoll rather than the apparently more logical beforepoll, because the application calling beforepoll doesn't constitute a promise to actually do anything.) Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> --- tools/libxl/libxl_event.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)