summaryrefslogtreecommitdiff
path: root/src/xcb_out.c
diff options
context:
space:
mode:
authorJamey Sharp <jamey@minilop.net>2006-02-24 02:17:36 -0800
committerJamey Sharp <jamey@minilop.net>2006-02-24 02:17:36 -0800
commitf27166f49b9ef6bdcce78429bffc724d1e4fb360 (patch)
treedc79641abc37172ff4b12cd7d3cd788e25dd0aeb /src/xcb_out.c
parent9463653b1e6dc0a9054266aa3eecb0839129b991 (diff)
Coalesce _xcb_writev into _xcb_out_write and simplify.
Diffstat (limited to 'src/xcb_out.c')
-rw-r--r--src/xcb_out.c45
1 files changed, 19 insertions, 26 deletions
diff --git a/src/xcb_out.c b/src/xcb_out.c
index a6b0350..145bddd 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)
@@ -251,12 +229,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)