[Xcb] problem with xcb_poll_for_reply (or xcb_wait_for_reply)

Julien Danjou julien at danjou.info
Wed Aug 6 12:20:55 PDT 2008


At 1218049705 time_t, Barton C Massey wrote:
> Is there something wrong about the following?
> 
>    while((ev = xcb_poll_for_event(globalconf.connection)))
>        xcb_handle_event(globalconf.evenths, ev);
>    select(...);
>    while((ev = xcb_poll_for_event(globalconf.connection)))
>        xcb_handle_event(globalconf.evenths, ev);
> 
> It shouldn't miss any events, as far as I know?

Well since you cannot lock the XCB event queue, I think you can still
miss events.

First xcb_poll_for_event() can return NULL, and in the mean time you
call select(), maybe your thread has been interrupted: meanwhile XCB has
received a reply on the socket and puts it in your queue.
So select() won't get it.

> Is there
> some reason you want to sync() here?  Or am I missing
> something?  As long as you don't want to try to
> asynchronously poll for replies, which is really hard with
> XCB, I think the above should be pretty OK...

I need to sync() for an unknown reason. If I don't, some of my requests
are not (pick one or several): sent to the X server, treated by the X
server, visible on screen.

> XCB is really designed for folks who want its new model for
> asynchrony.  This model is kind of ugly against existing
> toolkits, as it turns out.  We should try to figure out what
> to do about that, I guess.  xcb_select(...)?  I smell Xt
> here, and it doesn't smell pretty...

Well, in my case, the program need to do poll/select() stuff. X is not
the only path for events, so select/poll()'ing X in the way just seems
the obvious solution.

Cheers,
-- 
Julien Danjou
// ᐰ <julien at danjou.info>   http://julien.danjou.info
// 9A0D 5FD9 EB42 22F6 8974  C95C A462 B51E C2FE E5CD
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
Url : http://lists.freedesktop.org/archives/xcb/attachments/20080806/9c1c1c2b/attachment.pgp 


More information about the Xcb mailing list