[Xcb] [PATCH 0/3] RFC: Fixes to Xlib problems.

Ulrich Eckhardt doomster at knuut.de
Fri Oct 8 08:59:20 PDT 2010


On Friday 08 October 2010 15:00:20 Rami Ylimäki wrote:
> On 10/07/2010 08:12 PM, jamey at minilop.net wrote:
> > I can't accept xcb_peek_for_event because it is inherently not
> > thread-safe. I didn't look too closely, but I assume that means the
> > libX11 patch needs to be re-thought, right?
> 
> Could you clarify what you mean by it not being thread safe? The
> original intention of xcb_peek_for_event was to find out the sequence
> number of next event in XCB buffers. It only returns a copy of the next
> event header if an event has been read and does the copy when locked
> properly. No guarantee is given that the corresponding event exists in
> XCB after xcb_peek_for_event returns, but that should be OK.

I'm not sure what Jamey meant, but I also see the danger this presents in case 
of multiple threads. The problem is basically that it invites code like

  if(peek_for_event())
      handle_event();

which has a race condition when between the two calls some other thread 
removes and handles the event. At the very least, this function should come 
with a flashing yellow warning that such use as above will lead to problems.


Uli



More information about the Xcb mailing list