Make xcb_take_socket keep flushing until idle

_xcb_out_flush_to will drop the iolock in pthread_cond_wait allowing
other threads to queue new requests. When this happened,
there would be requests queued for the socket after _xcb_out_flush_to
returned, and xcb_take_socket would throw an assert.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=29875
Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Keith Packard 2011-12-01 10:28:51 +00:00 committed by Julien Danjou
parent 5ceeaaa429
commit 9b4d6f30a3

View File

@ -263,7 +263,13 @@ int xcb_take_socket(xcb_connection_t *c, void (*return_socket)(void *closure), v
return 0;
pthread_mutex_lock(&c->iolock);
get_socket_back(c);
ret = _xcb_out_flush_to(c, c->out.request);
/* _xcb_out_flush may drop the iolock allowing other threads to
* write requests, so keep flushing until we're done
*/
do
ret = _xcb_out_flush_to(c, c->out.request);
while (ret && c->out.request != c->out.request_written);
if(ret)
{
c->out.return_socket = return_socket;