Delete a useless level of indirection from _xcb_out_send's parameters.

_xcb_out_send needs _xcb_conn_wait to store back its progress so it can
be reinvoked to pick up where it left off---but then _xcb_out_send
guarantees that it leaves either an empty output vector or a shut-down
connection, so *its* callers never care how much progress was made.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Josh Triplett <josh@freedesktop.org>
This commit is contained in:
Jamey Sharp 2010-02-12 12:25:05 -08:00
parent a63fbc9d6c
commit 6dd8228a13
3 changed files with 9 additions and 13 deletions

View File

@ -102,10 +102,7 @@ static int write_setup(xcb_connection_t *c, xcb_auth_info_t *auth_info)
assert(count <= (int) (sizeof(parts) / sizeof(*parts)));
pthread_mutex_lock(&c->iolock);
{
struct iovec *parts_ptr = parts;
ret = _xcb_out_send(c, &parts_ptr, &count);
}
ret = _xcb_out_send(c, parts, count);
pthread_mutex_unlock(&c->iolock);
return ret;
}

View File

@ -52,7 +52,7 @@ static int write_block(xcb_connection_t *c, struct iovec *vector, int count)
vector[0].iov_base = c->out.queue;
vector[0].iov_len = c->out.queue_len;
c->out.queue_len = 0;
return _xcb_out_send(c, &vector, &count);
return _xcb_out_send(c, vector, count);
}
static void get_socket_back(xcb_connection_t *c)
@ -283,7 +283,7 @@ int xcb_writev(xcb_connection_t *c, struct iovec *vector, int count, uint64_t re
return 0;
pthread_mutex_lock(&c->iolock);
c->out.request += requests;
ret = _xcb_out_send(c, &vector, &count);
ret = _xcb_out_send(c, vector, count);
pthread_mutex_unlock(&c->iolock);
return ret;
}
@ -331,11 +331,11 @@ void _xcb_out_destroy(_xcb_out *out)
pthread_mutex_destroy(&out->reqlenlock);
}
int _xcb_out_send(xcb_connection_t *c, struct iovec **vector, int *count)
int _xcb_out_send(xcb_connection_t *c, struct iovec *vector, int count)
{
int ret = 1;
while(ret && *count)
ret = _xcb_conn_wait(c, &c->out.cond, vector, count);
while(ret && count)
ret = _xcb_conn_wait(c, &c->out.cond, &vector, &count);
c->out.request_written = c->out.request;
pthread_cond_broadcast(&c->out.cond);
return ret;
@ -348,12 +348,11 @@ int _xcb_out_flush_to(xcb_connection_t *c, uint64_t request)
return 1;
if(c->out.queue_len)
{
struct iovec vec, *vec_ptr = &vec;
int count = 1;
struct iovec vec;
vec.iov_base = c->out.queue;
vec.iov_len = c->out.queue_len;
c->out.queue_len = 0;
return _xcb_out_send(c, &vec_ptr, &count);
return _xcb_out_send(c, &vec, 1);
}
while(c->out.writing)
pthread_cond_wait(&c->out.cond, &c->iolock);

View File

@ -106,7 +106,7 @@ typedef struct _xcb_out {
int _xcb_out_init(_xcb_out *out);
void _xcb_out_destroy(_xcb_out *out);
int _xcb_out_send(xcb_connection_t *c, struct iovec **vector, int *count);
int _xcb_out_send(xcb_connection_t *c, struct iovec *vector, int count);
int _xcb_out_flush_to(xcb_connection_t *c, uint64_t request);