summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Roberts <neil@linux.intel.com>2013-07-09 14:10:45 +0100
committerKristian Høgsberg <krh@bitplanet.net>2013-07-09 17:59:56 -0400
commit12cea9559313c3503a7a321e684e3ef1ec7a6e49 (patch)
treee86f87255d1b491532804d730b6a1050dd7fb4a2
parent4cffa0fd61fde7760f2506b154b2af7d24b8c25f (diff)
wayland-client: Treat EOF when reading the wayland socket as an error
If EOF is encountered while reading from the Wayland socket, make wl_display_read_events() return -1 so that it will be treated as an error. The documentation for this function states that it will set errno when there is an error so it additionally makes up an errno of EPIPE. If we don't do this then when the compositor quits the Wayland socket will be become ready for reading but wl_display_dispatch will do nothing which typically makes the application take up 100% CPU. In particular eglSwapBuffers will likely get stuck in an infinite busy loop because it repeatedly calls wl_display_dispatch_queue while it waits for the frame callback. https://bugzilla.gnome.org/show_bug.cgi?id=703892
-rw-r--r--src/wayland-client.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/wayland-client.c b/src/wayland-client.c
index cb091ab..45aa372 100644
--- a/src/wayland-client.c
+++ b/src/wayland-client.c
@@ -876,7 +876,15 @@ read_events(struct wl_display *display)
if (errno != EAGAIN)
display_fatal_error(display, errno);
return -1;
+ } else if (total == 0) {
+ /* The compositor has closed the socket. This
+ * should be considered an error so we'll fake
+ * an errno */
+ errno = EPIPE;
+ display_fatal_error(display, errno);
+ return -1;
}
+
for (rem = total; rem >= 8; rem -= size) {
size = queue_event(display, rem);
if (size == -1) {