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:
parent
a63fbc9d6c
commit
6dd8228a13
|
@ -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)));
|
assert(count <= (int) (sizeof(parts) / sizeof(*parts)));
|
||||||
|
|
||||||
pthread_mutex_lock(&c->iolock);
|
pthread_mutex_lock(&c->iolock);
|
||||||
{
|
ret = _xcb_out_send(c, parts, count);
|
||||||
struct iovec *parts_ptr = parts;
|
|
||||||
ret = _xcb_out_send(c, &parts_ptr, &count);
|
|
||||||
}
|
|
||||||
pthread_mutex_unlock(&c->iolock);
|
pthread_mutex_unlock(&c->iolock);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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_base = c->out.queue;
|
||||||
vector[0].iov_len = c->out.queue_len;
|
vector[0].iov_len = c->out.queue_len;
|
||||||
c->out.queue_len = 0;
|
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)
|
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;
|
return 0;
|
||||||
pthread_mutex_lock(&c->iolock);
|
pthread_mutex_lock(&c->iolock);
|
||||||
c->out.request += requests;
|
c->out.request += requests;
|
||||||
ret = _xcb_out_send(c, &vector, &count);
|
ret = _xcb_out_send(c, vector, count);
|
||||||
pthread_mutex_unlock(&c->iolock);
|
pthread_mutex_unlock(&c->iolock);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -331,11 +331,11 @@ void _xcb_out_destroy(_xcb_out *out)
|
||||||
pthread_mutex_destroy(&out->reqlenlock);
|
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;
|
int ret = 1;
|
||||||
while(ret && *count)
|
while(ret && count)
|
||||||
ret = _xcb_conn_wait(c, &c->out.cond, vector, count);
|
ret = _xcb_conn_wait(c, &c->out.cond, &vector, &count);
|
||||||
c->out.request_written = c->out.request;
|
c->out.request_written = c->out.request;
|
||||||
pthread_cond_broadcast(&c->out.cond);
|
pthread_cond_broadcast(&c->out.cond);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -348,12 +348,11 @@ int _xcb_out_flush_to(xcb_connection_t *c, uint64_t request)
|
||||||
return 1;
|
return 1;
|
||||||
if(c->out.queue_len)
|
if(c->out.queue_len)
|
||||||
{
|
{
|
||||||
struct iovec vec, *vec_ptr = &vec;
|
struct iovec vec;
|
||||||
int count = 1;
|
|
||||||
vec.iov_base = c->out.queue;
|
vec.iov_base = c->out.queue;
|
||||||
vec.iov_len = c->out.queue_len;
|
vec.iov_len = c->out.queue_len;
|
||||||
c->out.queue_len = 0;
|
c->out.queue_len = 0;
|
||||||
return _xcb_out_send(c, &vec_ptr, &count);
|
return _xcb_out_send(c, &vec, 1);
|
||||||
}
|
}
|
||||||
while(c->out.writing)
|
while(c->out.writing)
|
||||||
pthread_cond_wait(&c->out.cond, &c->iolock);
|
pthread_cond_wait(&c->out.cond, &c->iolock);
|
||||||
|
|
|
@ -106,7 +106,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_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);
|
int _xcb_out_flush_to(xcb_connection_t *c, uint64_t request);
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue