[Xcb] [PATCH v2] Support xcb_discard_reply (was Do not block when calling reply() multiple times)

Jamey Sharp jamey at minilop.net
Mon Feb 8 19:31:39 PST 2010


Oh hey, you already sent the revised patch. Yay!

I have some small complaints, but I approve of this patch. Feel free to
push, though I hope you'll revise it one more time.

Reviewed-by: Jamey Sharp <jamey at minilop.net>

It looks like you can't discard a reply to a request sent via socket
handoff. I don't think it's a feature that needs to be implemented right
now, but it probably should be documented that this combination doesn't
work. (Unless it does, and I'm just confused.)

There are some code style mismatches: tabs instead of spaces, space
after for/if, braces not on their own line.

I'd have written this loop differently:

> +    prev_pend_next = &c->in.pending_replies;
> +    for (pend = c->in.pending_replies; pend; pend = pend->next) {
> +        if (XCB_SEQUENCE_COMPARE_32(pend->first_request, <, request)) {
> +            prev_pend_next = &pend->next;
> +            continue;
> +        }
> +
> +        if (XCB_SEQUENCE_COMPARE_32(pend->first_request, ==, request)) {
> +            /* Pending reply found. Mark for discard: */
> +            pend->flags |= XCB_REQUEST_DISCARD_REPLY;
> +            return;
> +        }
> +
> +        break;
> +    }

How about this?

    for(prev_pend = &c->in.pending_replies; *prev_pend; prev_pend = &(*prev_pend)->next)
    {
        if(XCB_SEQUENCE_COMPARE_32((*prev_pend)->first_request, >, request))
            break;
        if(XCB_SEQUENCE_COMPARE_32((*prev_pend)->first_request, ==, request))
        {
            /* Pending reply found. Mark for discard: */
            (*prev_pend)->flags |= XCB_REQUEST_DISCARD_REPLY;
            return;
        }
    }

Jamey
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
Url : http://lists.freedesktop.org/archives/xcb/attachments/20100208/84906ec5/attachment.pgp 


More information about the Xcb mailing list