client: wake-up threads on all return paths from read_events
authorMarek Chalupa <mchqwerty@gmail.com>
Wed, 10 Sep 2014 10:47:13 +0000 (12:47 +0200)
committerPekka Paalanen <pekka.paalanen@collabora.co.uk>
Thu, 11 Sep 2014 07:22:44 +0000 (10:22 +0300)
If wl_connection_read returned EAGAIN, we must wake up sleeping
threads. If we don't do this and the thread calling
wl_connection_read won't call wl_display_read_events again,
the sleeping threads will sleep indefinitely.

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
src/wayland-client.c

index 9f817f6..1b7a046 100644 (file)
@@ -1152,8 +1152,13 @@ read_events(struct wl_display *display)
        if (display->reader_count == 0) {
                total = wl_connection_read(display->connection);
                if (total == -1) {
-                       if (errno == EAGAIN)
+                       if (errno == EAGAIN) {
+                               /* we must wake up threads whenever
+                                * the reader_count dropped to 0 */
+                               display_wakeup_threads(display);
+
                                return 0;
+                       }
 
                        display_fatal_error(display, errno);
                        return -1;