From 6dd8228a137d280ce24cec604a419129d8ed0e8e Mon Sep 17 00:00:00 2001 From: Jamey Sharp Date: Fri, 12 Feb 2010 12:25:05 -0800 Subject: 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 Reviewed-by: Josh Triplett --- src/xcb_conn.c | 5 +---- src/xcb_out.c | 15 +++++++-------- src/xcbint.h | 2 +- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/xcb_conn.c b/src/xcb_conn.c index 1d37614..50a662b 100644 --- a/src/xcb_conn.c +++ b/src/xcb_conn.c @@ -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; } diff --git a/src/xcb_out.c b/src/xcb_out.c index b3050fe..afc12c1 100644 --- a/src/xcb_out.c +++ b/src/xcb_out.c @@ -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); diff --git a/src/xcbint.h b/src/xcbint.h index 154cca0..9d44238 100644 --- a/src/xcbint.h +++ b/src/xcbint.h @@ -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); -- cgit v1.2.3