summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJamey Sharp <jamey@minilop.net>2006-02-24 00:25:34 -0800
committerJamey Sharp <jamey@minilop.net>2006-02-24 00:25:34 -0800
commitcdf362f33a7bc4d412231de32e37ffb65a06d3f1 (patch)
tree2abc1889509dd60807ee3ff27cce021214c860f4 /src
parent4e91ae275e46e76de64ab089d6f13c1e9b6ddee6 (diff)
Bugfix: protect the output queue from being written while another thread is flushing it.
Diffstat (limited to 'src')
-rw-r--r--src/xcb_out.c8
1 files changed, 4 insertions, 4 deletions
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;