[Xcb] [PATCH v3:libxcb 1/2] Prevent reply waiters from being blocked.

Jamey Sharp jamey at minilop.net
Mon Mar 14 17:22:07 PDT 2011


Oooops. Sorry I dropped this. Pushed now, after re-reviewing to convince
myself again that this patch makes sense and is a good idea.

Jamey

On Wed, Oct 13, 2010 at 05:48:13PM +0300, Rami Ylimäki wrote:
> It's possible to call xcb_wait_for_reply more than once for a single
> request. In this case we are nice and let reply waiters continue so
> that they can notice that the reply is not available
> anymore. Otherwise an event waiter could just signal the reply waiter
> that got its reply to continue but leave a waiter for an earlier reply
> blocked.
> 
> Below is and example sequence for reproducing this problem.
> 
> thread #1 (XNextEvent)
>   - waits for events
> thread #2 (XSync)
>   - executes request #2
>   - waits for reply #2
> thread #1
>   - reads reply #2
>   - signals waiter of reply #2 to continue
>   - waits for events
> thread #2
>   - handles reply #2
> thread #3 (XCloseDisplay)
>   - executes request #3
>   - waits for reply #2
> thread #1
>   - reads reply #3
>   - nobody is waiting for reply #3 so don't signal
>   - wait for events
> 
> Of course it may be questionable to wait for a reply twice, but XCB
> should be smart enough to let clients continue if they choose to do
> so.
> 
> Signed-off-by: Rami Ylimäki <rami.ylimaki at vincit.fi>
> ---
>  src/xcb_in.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/src/xcb_in.c b/src/xcb_in.c
> index 80f5523..4ca7198 100644
> --- a/src/xcb_in.c
> +++ b/src/xcb_in.c
> @@ -212,9 +212,9 @@ static int read_packet(xcb_connection_t *c)
>  	    XCB_SEQUENCE_COMPARE_32(reader->request, <=, c->in.request_read);
>  	    reader = reader->next)
>  	{
> +            pthread_cond_signal(reader->data);
>              if(XCB_SEQUENCE_COMPARE_32(reader->request, ==, c->in.request_read))
>              {
> -                pthread_cond_signal(reader->data);
>                  break;
>              }
>  	}
> -- 
> 1.6.3.3
> 
> _______________________________________________
> Xcb mailing list
> Xcb at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/xcb
-------------- 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/20110314/46de44ed/attachment.pgp>


More information about the Xcb mailing list