From: Jamey Sharp Date: Fri, 24 Feb 2006 08:25:34 +0000 (-0800) Subject: Bugfix: protect the output queue from being written while another thread is flushing it. X-Git-Url: http://git.demorecorder.com/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cdf362f33a7bc4d412231de32e37ffb65a06d3f1;p=free-sw%2Fxcb%2Flibxcb Bugfix: protect the output queue from being written while another thread is flushing it. --- diff --git a/src/xcb_out.c b/src/xcb_out.c index e7d5323..89c7618 100644 --- a/src/xcb_out.c +++ b/src/xcb_out.c @@ -261,6 +261,9 @@ int _xcb_out_write(XCBConnection *c) int _xcb_out_write_block(XCBConnection *c, struct iovec *vector, size_t count) { + while(c->out.writing) + pthread_cond_wait(&c->out.cond, &c->iolock); + assert(!c->out.vec && !c->out.vec_len); while(count && c->out.queue_len + vector[0].iov_len < sizeof(c->out.queue)) { memcpy(c->out.queue + c->out.queue_len, vector[0].iov_base, vector[0].iov_len); @@ -275,8 +278,6 @@ int _xcb_out_write_block(XCBConnection *c, struct iovec *vector, size_t count) vector[0].iov_len = c->out.queue_len; c->out.queue_len = 0; - assert(!c->out.vec_len); - assert(!c->out.vec); c->out.vec_len = count; c->out.vec = vector; return _xcb_out_flush(c); @@ -288,8 +289,7 @@ int _xcb_out_flush(XCBConnection *c) struct iovec vec; if(c->out.queue_len) { - assert(!c->out.vec_len); - assert(!c->out.vec); + assert(!c->out.vec && !c->out.vec_len); vec.iov_base = c->out.queue; vec.iov_len = c->out.queue_len; c->out.vec = &vec;