[Xcb] [PATCH v2 2/2] Also signal special event waiters in _xcb_in_wake_up_next_reader

Uli Schlachter psychon at znc.in
Sat May 30 05:22:15 PDT 2015


Am 25.05.2015 um 10:52 schrieb Michel Dänzer:
> From: Michel Dänzer <michel.daenzer at amd.com>
> 
> Fixes occasional deadlock when quitting the Mesa demo glthreads with
> DRI3/Present.
> 
> Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
> ---
> 
> v2: Fix indentation of closing curly brace.
> 
>  src/xcb_in.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/src/xcb_in.c b/src/xcb_in.c
> index 322bed8..9a8cae1 100644
> --- a/src/xcb_in.c
> +++ b/src/xcb_in.c
> @@ -890,7 +890,14 @@ void _xcb_in_wake_up_next_reader(xcb_connection_t *c)
>      if(c->in.readers)
>          pthreadret = pthread_cond_signal(c->in.readers->data);
>      else
> +    {
> +        xcb_special_event_t *se;
> +
>          pthreadret = pthread_cond_signal(&c->in.event_cond);
> +        for (se = c->in.special_events; se; se = se->next) {
> +             pthreadret = pthread_cond_signal(&se->special_event_cond);
> +        }
> +    }
>      assert(pthreadret == 0);
>  }

Hrm. This is basically a pthread_cond_broadcast() waking up all threads, even
those for which we do not have a special event.

Can you explain why this is necessary at all? The function event_special()
should be handling this. This is called on all special events. It appends the
event to the xcb_special_event_t's event queue and then calls
pthread_cond_signal() on exactly this condition variable.

In my understanding, that should be enough. Why would we need a "wake up all
waiting threads and let them figure out if they have to do something themselves"?

Cheers,
Uli
-- 
- Captain, I think I should tell you I've never
  actually landed a starship before.
- That's all right, Lieutenant, neither have I.


More information about the Xcb mailing list