Move c->out.vec refs out of _xcb_out_write up to _xcb_conn_wait.

This commit is contained in:
Jamey Sharp 2006-03-08 14:21:16 -08:00
parent c491eeb9a9
commit 621f891c49
3 changed files with 11 additions and 11 deletions

View File

@ -231,7 +231,7 @@ int _xcb_conn_wait(XCBConnection *c, const int should_write, pthread_cond_t *con
ret = ret && _xcb_in_read(c); ret = ret && _xcb_in_read(c);
if(FD_ISSET(c->fd, &wfds)) if(FD_ISSET(c->fd, &wfds))
ret = ret && _xcb_out_write(c); ret = ret && _xcb_out_write(c, &c->out.vec, &c->out.vec_len);
} }
if(should_write) if(should_write)

View File

@ -207,29 +207,29 @@ void _xcb_out_destroy(_xcb_out *out)
} }
/* precondition: there must be something for us to write. */ /* precondition: there must be something for us to write. */
int _xcb_out_write(XCBConnection *c) int _xcb_out_write(XCBConnection *c, struct iovec **vector, int *count)
{ {
int n; int n;
assert(!c->out.queue_len); assert(!c->out.queue_len);
n = writev(c->fd, c->out.vec, c->out.vec_len); n = writev(c->fd, *vector, *count);
if(n < 0 && errno == EAGAIN) if(n < 0 && errno == EAGAIN)
return 1; return 1;
if(n <= 0) if(n <= 0)
return 0; return 0;
for(; c->out.vec_len; --c->out.vec_len, ++c->out.vec) for(; *count; --*count, ++*vector)
{ {
int cur = c->out.vec->iov_len; int cur = (*vector)->iov_len;
if(cur > n) if(cur > n)
cur = n; cur = n;
c->out.vec->iov_len -= cur; (*vector)->iov_len -= cur;
c->out.vec->iov_base = (char *) c->out.vec->iov_base + cur; (*vector)->iov_base = (char *) (*vector)->iov_base + cur;
n -= cur; n -= cur;
if(c->out.vec->iov_len) if((*vector)->iov_len)
break; break;
} }
if(!c->out.vec_len) if(!*count)
c->out.vec = 0; *vector = 0;
assert(n == 0); assert(n == 0);
return 1; return 1;
} }

View File

@ -76,7 +76,7 @@ typedef struct _xcb_out {
int _xcb_out_init(_xcb_out *out); int _xcb_out_init(_xcb_out *out);
void _xcb_out_destroy(_xcb_out *out); void _xcb_out_destroy(_xcb_out *out);
int _xcb_out_write(XCBConnection *c); int _xcb_out_write(XCBConnection *c, struct iovec **vector, int *count);
int _xcb_out_write_block(XCBConnection *c, struct iovec *vector, size_t count); int _xcb_out_write_block(XCBConnection *c, struct iovec *vector, size_t count);
int _xcb_out_flush(XCBConnection *c); int _xcb_out_flush(XCBConnection *c);