diff options
author | Jamey Sharp <jamey@minilop.net> | 2006-03-12 13:20:29 -0800 |
---|---|---|
committer | Jamey Sharp <jamey@minilop.net> | 2006-03-12 13:20:29 -0800 |
commit | b83f18a4cc2303dfda59807d56e16bbc5c18b09d (patch) | |
tree | 2dcd63657899a2f18433a458fa0493047be7e30b /src | |
parent | fb61c94d685a254ef0702a2e2093b8cdda02d514 (diff) |
Only _xcb_conn_wait calls _xcb_out_write now, so move it to xcb_conn.c and make it static.
Diffstat (limited to 'src')
-rw-r--r-- | src/xcb_conn.c | 31 | ||||
-rw-r--r-- | src/xcb_out.c | 29 | ||||
-rw-r--r-- | src/xcbint.h | 1 |
3 files changed, 30 insertions, 31 deletions
diff --git a/src/xcb_conn.c b/src/xcb_conn.c index 1b3e1a2..2da3150 100644 --- a/src/xcb_conn.c +++ b/src/xcb_conn.c @@ -33,6 +33,7 @@ #include <netinet/in.h> #include <sys/select.h> #include <sys/fcntl.h> +#include <errno.h> #include "xcb.h" #include "xcbint.h" @@ -138,6 +139,34 @@ static int read_setup(XCBConnection *c) return 1; } +/* precondition: there must be something for us to write. */ +static int write_vec(XCBConnection *c, struct iovec **vector, int *count) +{ + int n; + assert(!c->out.queue_len); + n = writev(c->fd, *vector, *count); + if(n < 0 && errno == EAGAIN) + return 1; + if(n <= 0) + return 0; + + for(; *count; --*count, ++*vector) + { + int cur = (*vector)->iov_len; + if(cur > n) + cur = n; + (*vector)->iov_len -= cur; + (*vector)->iov_base = (char *) (*vector)->iov_base + cur; + n -= cur; + if((*vector)->iov_len) + break; + } + if(!*count) + *vector = 0; + assert(n == 0); + return 1; +} + /* Public interface */ XCBConnSetupSuccessRep *XCBGetSetup(XCBConnection *c) @@ -233,7 +262,7 @@ int _xcb_conn_wait(XCBConnection *c, pthread_cond_t *cond, struct iovec **vector ret = ret && _xcb_in_read(c); if(FD_ISSET(c->fd, &wfds)) - ret = ret && _xcb_out_write(c, vector, count); + ret = ret && write_vec(c, vector, count); } if(count) diff --git a/src/xcb_out.c b/src/xcb_out.c index b0130e7..2b1a434 100644 --- a/src/xcb_out.c +++ b/src/xcb_out.c @@ -29,7 +29,6 @@ #include <stdlib.h> #include <unistd.h> #include <string.h> -#include <errno.h> #include "xcb.h" #include "xcbext.h" @@ -224,34 +223,6 @@ void _xcb_out_destroy(_xcb_out *out) pthread_mutex_destroy(&out->reqlenlock); } -/* precondition: there must be something for us to write. */ -int _xcb_out_write(XCBConnection *c, struct iovec **vector, int *count) -{ - int n; - assert(!c->out.queue_len); - n = writev(c->fd, *vector, *count); - if(n < 0 && errno == EAGAIN) - return 1; - if(n <= 0) - return 0; - - for(; *count; --*count, ++*vector) - { - int cur = (*vector)->iov_len; - if(cur > n) - cur = n; - (*vector)->iov_len -= cur; - (*vector)->iov_base = (char *) (*vector)->iov_base + cur; - n -= cur; - if((*vector)->iov_len) - break; - } - if(!*count) - *vector = 0; - assert(n == 0); - return 1; -} - int _xcb_out_send(XCBConnection *c, struct iovec **vector, int *count) { int ret = 1; diff --git a/src/xcbint.h b/src/xcbint.h index e90ede2..7b32248 100644 --- a/src/xcbint.h +++ b/src/xcbint.h @@ -74,7 +74,6 @@ typedef struct _xcb_out { int _xcb_out_init(_xcb_out *out); void _xcb_out_destroy(_xcb_out *out); -int _xcb_out_write(XCBConnection *c, struct iovec **vector, int *count); int _xcb_out_send(XCBConnection *c, struct iovec **vector, int *count); int _xcb_out_flush_to(XCBConnection *c, unsigned int request); |