aboutsummaryrefslogtreecommitdiffstats
path: root/src/event-loop.c
diff options
context:
space:
mode:
authorChristopher James Halse Rogers <christopher.halse.rogers@canonical.com>2017-08-28 18:03:38 +1000
committerDaniel Stone <daniels@collabora.com>2017-12-04 19:45:38 +0000
commited7ad31ac2fa3fb1aa03ed1435e6673b6b070f55 (patch)
tree9f1c92bde7e55570af38a3545774f332e834e3c9 /src/event-loop.c
parentprotocol: Add deprecation note about wl_shell (diff)
downloadwayland-ed7ad31ac2fa3fb1aa03ed1435e6673b6b070f55.tar
wayland-ed7ad31ac2fa3fb1aa03ed1435e6673b6b070f55.tar.gz
wayland-ed7ad31ac2fa3fb1aa03ed1435e6673b6b070f55.tar.bz2
wayland-ed7ad31ac2fa3fb1aa03ed1435e6673b6b070f55.tar.lz
wayland-ed7ad31ac2fa3fb1aa03ed1435e6673b6b070f55.tar.xz
wayland-ed7ad31ac2fa3fb1aa03ed1435e6673b6b070f55.tar.zst
wayland-ed7ad31ac2fa3fb1aa03ed1435e6673b6b070f55.zip
eventloop: clarify post_dispatch_check()
This *technically* changes the semantics of the return value of the source callbacks. Previously you could return a negative number from a source callback and it would prevent *other* source callbacks from triggering a subsequent recheck. Doing that seems like such a bad idea it's not worth supporting. v2: Log this case if it is hit, so we don't silently change behaviour. Signed-off-by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com> Reviewed-by: Daniel Stone <daniels@collabora.com>
Diffstat (limited to 'src/event-loop.c')
-rw-r--r--src/event-loop.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/event-loop.c b/src/event-loop.c
index 49e48bf..eb2dce6 100644
--- a/src/event-loop.c
+++ b/src/event-loop.c
@@ -29,6 +29,7 @@
#include <signal.h>
#include <stdlib.h>
#include <stdint.h>
+#include <stdbool.h>
#include <string.h>
#include <fcntl.h>
#include <sys/socket.h>
@@ -559,19 +560,26 @@ wl_event_loop_destroy(struct wl_event_loop *loop)
free(loop);
}
-static int
+static bool
post_dispatch_check(struct wl_event_loop *loop)
{
struct epoll_event ep;
struct wl_event_source *source, *next;
- int n;
+ bool needs_recheck = false;
ep.events = 0;
- n = 0;
- wl_list_for_each_safe(source, next, &loop->check_list, link)
- n += source->interface->dispatch(source, &ep);
+ wl_list_for_each_safe(source, next, &loop->check_list, link) {
+ int dispatch_result;
+
+ dispatch_result = source->interface->dispatch(source, &ep);
+ if (dispatch_result < 0) {
+ wl_log("Source dispatch function returned negative value!");
+ wl_log("This would previously accidentally suppress a follow-up dispatch");
+ }
+ needs_recheck |= dispatch_result != 0;
+ }
- return n;
+ return needs_recheck;
}
/** Dispatch the idle sources
@@ -619,7 +627,7 @@ wl_event_loop_dispatch(struct wl_event_loop *loop, int timeout)
{
struct epoll_event ep[32];
struct wl_event_source *source;
- int i, count, n;
+ int i, count;
wl_event_loop_dispatch_idle(loop);
@@ -637,9 +645,7 @@ wl_event_loop_dispatch(struct wl_event_loop *loop, int timeout)
wl_event_loop_dispatch_idle(loop);
- do {
- n = post_dispatch_check(loop);
- } while (n > 0);
+ while (post_dispatch_check(loop));
return 0;
}