From: Ian Jackson Date: Fri, 10 Jan 2020 13:19:36 +0000 (+0000) Subject: libxl: event: Move poller pipe emptying to the end of afterpoll X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=0b70b2ff8f5a61196d090cc70040a20178327347;p=people%2Fdwmw2%2Fxen.git libxl: event: Move poller pipe emptying to the end of afterpoll This seems neater. It doesn't have any significant effect because: The poller fd wouldn't be emptied by time_occurs. It would only be woken by time_occurs as a result of an ao completing, or by libxl__egc_ao_cleanup_1_baton. But ...1_baton won't be called in between (for one thing, this would violate the rule of not still having the active caller when ...1_baton is called). While discussing this patch, I noticed that there is a possibility (in libxl in general) that poller_put might be called on a woken poller. It would probably be sensible at some point to make poller_get empty the pipe, at least if the pipe_nonempty flag is set. Signed-off-by: Ian Jackson Tested-by: George Dunlap Reviewed-by: George Dunlap --- v3: Completely revised commit message; now we think this is just cleanup. --- diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c index 5f6a607d80..7c5387e94f 100644 --- a/tools/libxl/libxl_event.c +++ b/tools/libxl/libxl_event.c @@ -1453,12 +1453,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(gc, "read wakeup", e, 0); - } - for (;;) { libxl__ev_time *etime = LIBXL_TAILQ_FIRST(&CTX->etimes); if (!etime) @@ -1473,6 +1467,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(gc, "read wakeup", e, 0); + } } void libxl_osevent_afterpoll(libxl_ctx *ctx, int nfds, const struct pollfd *fds,