X-Git-Url: http://git.demorecorder.com/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fxcb_out.c;h=8eb8a7a6d2b0ea0bc9133357c7aaa37db206d36a;hb=86ce18c22c8daebe8796d3c38e8a1d496ab6e8de;hp=a6b03509d86cc569824da8c49d08b4bbd3aaa4e3;hpb=838317f4d305e07f35ddd99e2ebccfa8fac680c6;p=free-sw%2Fxcb%2Flibxcb diff --git a/src/xcb_out.c b/src/xcb_out.c index a6b0350..8eb8a7a 100644 --- a/src/xcb_out.c +++ b/src/xcb_out.c @@ -58,28 +58,6 @@ static int force_sequence_wrap(XCBConnection *c) return ret; } -static int _xcb_writev(const int fd, struct iovec *vec, int count) -{ - int n = writev(fd, vec, count); - if(n > 0) - { - int rem = n; - for(; count; --count, ++vec) - { - int cur = vec->iov_len; - if(cur > rem) - cur = rem; - vec->iov_len -= cur; - vec->iov_base = (char *) vec->iov_base + cur; - rem -= cur; - if(vec->iov_len) - break; - } - assert(rem == 0); - } - return n; -} - /* Public interface */ CARD32 XCBGetMaximumRequestLength(XCBConnection *c) @@ -101,7 +79,7 @@ CARD32 XCBGetMaximumRequestLength(XCBConnection *c) return c->out.maximum_request_length; } -int XCBSendRequest(XCBConnection *c, unsigned int *request, struct iovec *vector, const XCBProtocolRequest *req) +int XCBSendRequest(XCBConnection *c, unsigned int *request, int flags, struct iovec *vector, const XCBProtocolRequest *req) { static const char pad[3]; int ret; @@ -127,7 +105,7 @@ int XCBSendRequest(XCBConnection *c, unsigned int *request, struct iovec *vector ((CARD8 *) vector[0].iov_base)[1] = req->opcode; /* do we need to work around the X server bug described in glx.xml? */ - if(strcmp(req->ext->name, "GLX") && + if(!req->isvoid && strcmp(req->ext->name, "GLX") && ((req->opcode == 17 && ((CARD32 *) vector[0].iov_base)[0] == 0x10004) || req->opcode == 21)) workaround = WORKAROUND_GLX_GET_FB_CONFIGS_BUG; @@ -139,17 +117,14 @@ int XCBSendRequest(XCBConnection *c, unsigned int *request, struct iovec *vector for(i = 0; i < req->count; ++i) longlen += (vector[i].iov_len + 3) >> 2; - if(longlen > c->setup->maximum_request_length) - { - if(longlen > XCBGetMaximumRequestLength(c)) - return 0; /* server can't take this; maybe need BIGREQUESTS? */ - } - else + if(longlen <= c->setup->maximum_request_length) { /* we don't need BIGREQUESTS. */ shortlen = longlen; longlen = 0; } + else if(longlen > XCBGetMaximumRequestLength(c)) + return 0; /* server can't take this; maybe need BIGREQUESTS? */ padded = #ifdef HAVE_ALLOCA @@ -197,8 +172,7 @@ int XCBSendRequest(XCBConnection *c, unsigned int *request, struct iovec *vector *request = ++c->out.request; - if(!req->isvoid) - _xcb_in_expect_reply(c, *request, workaround); + _xcb_in_expect_reply(c, *request, workaround, flags); ret = _xcb_out_write_block(c, padded, padlen); pthread_mutex_unlock(&c->iolock); @@ -251,12 +225,27 @@ int _xcb_out_write(XCBConnection *c) { int n; assert(!c->out.queue_len); - n = _xcb_writev(c->fd, c->out.vec, c->out.vec_len); - while(c->out.vec_len && !c->out.vec[0].iov_len) - ++c->out.vec, --c->out.vec_len; + n = writev(c->fd, c->out.vec, c->out.vec_len); + if(n < 0 && errno == EAGAIN) + return 1; + if(n <= 0) + return 0; + + for(; c->out.vec_len; --c->out.vec_len, ++c->out.vec) + { + int cur = c->out.vec->iov_len; + if(cur > n) + cur = n; + c->out.vec->iov_len -= cur; + c->out.vec->iov_base = (char *) c->out.vec->iov_base + cur; + n -= cur; + if(c->out.vec->iov_len) + break; + } if(!c->out.vec_len) c->out.vec = 0; - return (n > 0) || (n < 0 && errno == EAGAIN); + assert(n == 0); + return 1; } int _xcb_out_write_block(XCBConnection *c, struct iovec *vector, size_t count)