[Xcb] [PATCH 2/3] Do not block when calling reply() multiple times.

Jamey Sharp jamey at minilop.net
Mon Feb 8 18:58:17 PST 2010


On Tue, Feb 2, 2010 at 1:50 PM, Peter Harris <pharris at opentext.com> wrote:
> On 2010-02-02 16:05, Julien Danjou wrote:
>> At 1265143814 time_t, Peter Harris wrote:
>>> My current beef with the patch is that it requires horrible typecast
>>> gymnastics to convert a specific cookie type to an xcb_void_cookie_t.
>>> I'm not sure if that can be fixed without either breaking existing apps
>>> or adding a gazillion request-specific discard functions.
>>
>> Just ask for the sequence rather than the cookie.
>> This is how it is done in various place like xcb_wait_for_reply().
>
> Yeah, but xcb_wait_for_reply is an implementation detail. None of the
> documented API take a sequence number. The cookie is opaque, publicly.

No, if it's in an installed header file, it's deliberately public. I
worked to avoid Xlib's mistake of installing header files that
applications are supposed to pretend don't exist.

xcbext.h is an interesting case: It's public and part of the stable
API/ABI. The only reason it's separate is because I expected people
wouldn't particularly want to use it, not because I want people to
avoid using it. But that may have been a dumb reason to split it.

All this is even documented at
<http://xcb.freedesktop.org/ProtocolExtensionApi/> and
<http://xcb.freedesktop.org/ProtocolStubApi/#xcb_name_cookie_t>.

> That said, we could document the contents of cookies and ask for the
> sequence number. But that doesn't feel any less bad than the horrible
> typecast gymnastics. Or maybe I'm over-thinking things.

I agree that it isn't ideal, but this is C, so we live with it.
Requiring typecasts means we have no more type-safety than just
accepting the sequence number. Let's go with the approach that's least
ugly for callers: pass the sequence number.

Also, as Eamon says, please make discard work for unchecked requests
and anything else without flags. That case is a bit obnoxious since it
requires inserting into a sorted list, but that's not a big deal.

I look forward to seeing the revised patch with these two changes!

Jamey


More information about the Xcb mailing list