[PATCH] client: broadcast the right pthread_cond variable

Marek Chalupa mchqwerty at gmail.com
Tue Aug 5 02:42:01 PDT 2014


In previous commit we removed unused variables. One of them was
pthread_cond_t that was formerly used when reading from display, but
later was (erroneously) made unused. This patch fixes this error
and is a fix for the failing test introduced few patches ago (tests:
test if thread can block on error)
---
 src/wayland-client.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/wayland-client.c b/src/wayland-client.c
index 844138b..68a91f6 100644
--- a/src/wayland-client.c
+++ b/src/wayland-client.c
@@ -129,6 +129,12 @@ display_fatal_error(struct wl_display *display, int error)
 		error = EFAULT;
 
 	display->last_error = error;
+
+       pthread_cond_broadcast(&display->reader_cond);
+       /* prevent from indefinite looping in read_events()
+	* (when calling pthread_cond_wait under condition
+	* display->read_serial == serial) */
+       ++display->read_serial;
 }
 
 /**
@@ -177,6 +183,16 @@ display_protocol_error(struct wl_display *display, uint32_t code,
 	display->protocol_error.id = id;
 	display->protocol_error.interface = intf;
 
+	/*
+	 * here it is not necessary to broadcast reader's cond like in
+	 * display_fatal_error, because this function is called from
+	 * an event handler and that means that read_events() is done
+	 * and woke up all threads. Since wl_display_prepare_read()
+	 * fails when there are events in the queue, no threads
+	 * can sleep in read_events() during dispatching
+	 * (and therefore during calling this function), so this is safe.
+	 */
+
 	pthread_mutex_unlock(&display->mutex);
 }
 
-- 
2.0.4



More information about the wayland-devel mailing list