X-Git-Url: http://git.demorecorder.com/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fxcb_out.c;h=d6082fc7bf5323a6b4fa1da171975a510df89c06;hb=9b4d6f30a339e2d18ebaea98149da81aba453216;hp=fe71193213d2ea8bc7494dcb08de5dfc82bfbf6b;hpb=ee1bc1d28a1bda0526db90139edc1304d2ef3d7c;p=free-sw%2Fxcb%2Flibxcb diff --git a/src/xcb_out.c b/src/xcb_out.c index fe71193..d6082fc 100644 --- a/src/xcb_out.c +++ b/src/xcb_out.c @@ -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; @@ -343,6 +349,15 @@ int _xcb_out_send(xcb_connection_t *c, struct iovec *vector, int count) return ret; } +void _xcb_out_send_sync(xcb_connection_t *c) +{ + /* wait for other writing threads to get out of my way. */ + while(c->out.writing) + pthread_cond_wait(&c->out.cond, &c->iolock); + get_socket_back(c); + send_sync(c); +} + int _xcb_out_flush_to(xcb_connection_t *c, uint64_t request) { assert(XCB_SEQUENCE_COMPARE(request, <=, c->out.request));