[Xcb] [PATCH v2 2/2] Also signal special event waiters in _xcb_in_wake_up_next_reader
Michel Dänzer
michel at daenzer.net
Sun May 31 19:09:41 PDT 2015
On 30.05.2015 21:22, Uli Schlachter wrote:
> 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"?
I can't explain why, but what you're saying applies to "normal" events
as well, doesn't it? _xcb_in_wake_up_next_reader() signals
c->in.event_cond, even though read_packet() already does the same. This
change is mirroring that for special events.
--
Earthling Michel Dänzer | http://www.amd.com
Libre software enthusiast | Mesa and X developer
More information about the Xcb
mailing list