Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 1 | From 525fa9ded72d22b53c5eb366f61e2ac1d407a2db Mon Sep 17 00:00:00 2001 |
| 2 | From: Awais Belal <awais_belal@mentor.com> |
| 3 | Date: Thu, 8 Oct 2015 13:49:31 +0500 |
| 4 | Subject: [PATCH] sharedtex_mt: fix rendering thread hang |
| 5 | |
| 6 | XNextEvent is a blocking call which locks up the display mutex |
| 7 | this causes the rendering threads to hang when they try call |
| 8 | glXSwapBuffers() as that tries to take the same mutex in |
| 9 | underlying calls through XCopyArea(). |
| 10 | So we only go to XNextEvent when it has at least one event |
| 11 | and we wouldn't lock indefinitely. |
| 12 | |
| 13 | Signed-off-by: Awais Belal <awais_belal@mentor.com> |
| 14 | Upstream-Status: Backport (2b304e765695d385fd3bf414e6e444020bedb0a8) |
| 15 | |
| 16 | --- |
| 17 | src/xdemos/sharedtex_mt.c | 9 +++++++-- |
| 18 | 1 file changed, 7 insertions(+), 2 deletions(-) |
| 19 | |
| 20 | diff --git a/src/xdemos/sharedtex_mt.c b/src/xdemos/sharedtex_mt.c |
| 21 | index a90903a..1d503c4 100644 |
| 22 | --- a/src/xdemos/sharedtex_mt.c |
| 23 | +++ b/src/xdemos/sharedtex_mt.c |
| 24 | @@ -420,9 +420,14 @@ Resize(struct window *h, unsigned int width, unsigned int height) |
| 25 | static void |
| 26 | EventLoop(void) |
| 27 | { |
| 28 | + int i; |
| 29 | + XEvent event; |
| 30 | while (1) { |
| 31 | - int i; |
| 32 | - XEvent event; |
| 33 | + /* Do we have an event? */ |
| 34 | + if (XPending(gDpy) == 0) { |
| 35 | + usleep(10000); |
| 36 | + continue; |
| 37 | + } |
| 38 | XNextEvent(gDpy, &event); |
| 39 | for (i = 0; i < NumWindows; i++) { |
| 40 | struct window *h = &Windows[i]; |
| 41 | -- |
| 42 | 1.9.1 |
| 43 | |