[Xcb] Disconnecting while waiting for events in other threads.
Adrian Ratnapala
adrian.ratnapala at gmail.com
Mon Mar 31 09:48:02 PDT 2014
Thanks Uli,
I had planned to write a C example myself, and you have saved me a lot of time.
> I tried to capture this behavior in the attached example. I don't have any
> problem with it. Does it do what you would want it to do?
So you mean this should be safe, and there is a bug either in my
program probably in my program (see below) and not in libxcb. Good.
Your program works without hanging, but I couldn't make it reproduce
the problem sequence of events. For me the trouble starts when the
event thread begins blocking after the MapRequest is sent but *before*
the window thread waits for a reply.
However, I now see that it is not hanging in `xcb_request_check()`.
It hangs because the event thread never terminates even when I close
the connection. And we already know that there is a problem with my
approach there.
And this brings up a few topics:
(A) Don't call xcb_connection_has_error on a closed connection. Ok,
I'll stop doing that.
(B) wait_for_event() sometimes doesn't terminate when another thread
closes the display (with either XCloseDisplay() or xcb_disconnect).
As explained above.
But then I don't even know if it supposed to be safe to close the
display while another thread is waiting for events.
(C) Xlib. As far as I know, Xlib demands that I first call
XInitThreads and then either only use that Xlib Display from one
thread or else protect it using XLockDisplay(). I think this is what
I am doing (but I should check). But I am certainly using the
corresondiing XCB connection from multiple threads.
More information about the Xcb
mailing list