[PATCH 3/3] client: cancel read in wl_display_read_events() when last_error is set
Marek Chalupa
mchqwerty at gmail.com
Wed Sep 10 03:47:14 PDT 2014
Calling wl_display_read_events() after an error should be equivalent
to wl_display_cancel_read(), so that display state is consistent.
Thanks to Pekka Paalanen <pekka.paalanen at collabora.co.uk>
for pointing that out.
Signed-off-by: Marek Chalupa <mchqwerty at gmail.com>
---
src/wayland-client.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/wayland-client.c b/src/wayland-client.c
index 1b7a046..b0f77b9 100644
--- a/src/wayland-client.c
+++ b/src/wayland-client.c
@@ -1192,6 +1192,14 @@ read_events(struct wl_display *display)
return 0;
}
+static void
+cancel_read(struct wl_display *display)
+{
+ display->reader_count--;
+ if (display->reader_count == 0)
+ display_wakeup_threads(display);
+}
+
/** Read events from display file descriptor
*
* \param display The display context object
@@ -1219,6 +1227,7 @@ wl_display_read_events(struct wl_display *display)
pthread_mutex_lock(&display->mutex);
if (display->last_error) {
+ cancel_read(display);
pthread_mutex_unlock(&display->mutex);
errno = display->last_error;
@@ -1365,9 +1374,7 @@ wl_display_cancel_read(struct wl_display *display)
{
pthread_mutex_lock(&display->mutex);
- display->reader_count--;
- if (display->reader_count == 0)
- display_wakeup_threads(display);
+ cancel_read(display);
pthread_mutex_unlock(&display->mutex);
}
--
1.9.3
More information about the wayland-devel
mailing list