forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-02-13 e440ec23c5a540cdd3f7464e8779219be6fd3d95
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
From 5235a7f3692a4c3c90dd4ac1be3c670388904bbe Mon Sep 17 00:00:00 2001
From: Tatu Frisk <tatu.frisk@ge.com>
Date: Tue, 14 Mar 2017 14:41:27 +0200
Subject: [PATCH] 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.
 
Upstream-Status: Submitted [https://patchwork.freedesktop.org/patch/171458/]
 
This patch needs to be removed once the corresponding patch has been merged upstream.
 
https://patchwork.freedesktop.org/patch/171458/
 
Signed-off-by: Tatu Frisk <tatu.frisk@ge.com>
Signed-off-by: Jose Alarcon <jose.alarcon@ge.com>
 
[Refreshed for 1.6.7 update]
Signed-off-by: Armin Kuster <akuster808@gmail.com>
 
---
 src/xcb_io.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)
 
Index: libX11-1.6.7/src/xcb_io.c
===================================================================
--- libX11-1.6.7.orig/src/xcb_io.c
+++ libX11-1.6.7/src/xcb_io.c
@@ -620,18 +620,14 @@ Status _XReply(Display *dpy, xReply *rep
         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;