summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTatu Frisk <tatu.frisk@ge.com>2017-03-14 14:41:27 +0200
committerAdam Jackson <ajax@nwnk.net>2021-12-03 15:08:40 +0000
commit93a050c3ad2d2264d3880db3791387b1a9bf2e9e (patch)
tree0e7507fae6aaff67010dcf7770258225e96b7828 /src
parent8382253010267b93c9aeffc769e3f5e43d698094 (diff)
downloadxorg-lib-libX11-93a050c3ad2d2264d3880db3791387b1a9bf2e9e.tar.gz
Fix hanging issue in _XReply
Assume event queue is empty if another thread is blocking waiting for event. If one thread was blocking waiting for an event and another thread sent a reply to the X server, both threads got blocked until an event was received. Signed-off-by: Tatu Frisk <tatu.frisk@ge.com> Signed-off-by: Jose Alarcon <jose.alarcon@ge.com>
Diffstat (limited to 'src')
-rw-r--r--src/xcb_io.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/xcb_io.c b/src/xcb_io.c
index 4be75408..dff441ff 100644
--- a/src/xcb_io.c
+++ b/src/xcb_io.c
@@ -704,18 +704,14 @@ Status _XReply(Display *dpy, xReply *rep, int extra, Bool discard)
if(dpy->xcb->event_owner == XlibOwnsEventQueue)
{
xcb_generic_reply_t *event;
- /* If some thread is already waiting for events,
- * it will get the first one. That thread must
- * process that event before we can continue. */
- /* FIXME: That event might be after this reply,
- * and might never even come--or there might be
- * multiple threads trying to get events. */
- while(dpy->xcb->event_waiter)
- { /* need braces around ConditionWait */
- ConditionWait(dpy, dpy->xcb->event_notify);
- }
- while((event = poll_for_event(dpy, True)))
- handle_response(dpy, event, True);
+
+ /* Assume event queue is empty if another thread is blocking
+ * waiting for event. */
+ if(!dpy->xcb->event_waiter)
+ {
+ while((event = poll_for_response(dpy)))
+ handle_response(dpy, event, True);
+ }
}
req->reply_waiter = 0;