diff options
-rw-r--r-- | src/xcb_conn.c | 4 | ||||
-rw-r--r-- | src/xcb_in.c | 23 | ||||
-rw-r--r-- | src/xcb_util.c | 21 | ||||
-rw-r--r-- | src/xcbint.h | 1 |
4 files changed, 24 insertions, 25 deletions
diff --git a/src/xcb_conn.c b/src/xcb_conn.c index de55951..698cf51 100644 --- a/src/xcb_conn.c +++ b/src/xcb_conn.c @@ -88,7 +88,7 @@ static int read_setup(XCBConnection *c) if(!c->setup) return 0; - if(_xcb_read_block(c->fd, c->setup, sizeof(XCBConnSetupGenericRep)) != sizeof(XCBConnSetupGenericRep)) + if(_xcb_in_read_block(c, c->setup, sizeof(XCBConnSetupGenericRep)) != sizeof(XCBConnSetupGenericRep)) return 0; { @@ -98,7 +98,7 @@ static int read_setup(XCBConnection *c) c->setup = tmp; } - if(_xcb_read_block(c->fd, (char *) c->setup + sizeof(XCBConnSetupGenericRep), c->setup->length * 4) <= 0) + if(_xcb_in_read_block(c, (char *) c->setup + sizeof(XCBConnSetupGenericRep), c->setup->length * 4) <= 0) return 0; /* 0 = failed, 2 = authenticate, 1 = success */ diff --git a/src/xcb_in.c b/src/xcb_in.c index ead0178..dc12fa2 100644 --- a/src/xcb_in.c +++ b/src/xcb_in.c @@ -153,6 +153,27 @@ static int read_packet(XCBConnection *c) return 1; /* I have something for you... */ } +static int read_block(const int fd, void *buf, const size_t len) +{ + int done = 0; + while(done < len) + { + int ret = read(fd, ((char *) buf) + done, len - done); + if(ret > 0) + done += ret; + if(ret < 0 && errno == EAGAIN) + { + fd_set fds; + FD_ZERO(&fds); + FD_SET(fd, &fds); + ret = select(fd + 1, &fds, 0, 0, 0); + } + if(ret <= 0) + return ret; + } + return len; +} + /* Public interface */ void *XCBWaitForReply(XCBConnection *c, unsigned int request, XCBGenericError **e) @@ -348,7 +369,7 @@ int _xcb_in_read_block(XCBConnection *c, void *buf, int len) if(len > done) { - int ret = _xcb_read_block(c->fd, (char *) buf + done, len - done); + int ret = read_block(c->fd, (char *) buf + done, len - done); if(ret <= 0) return ret; } diff --git a/src/xcb_util.c b/src/xcb_util.c index c9c7f92..b7f5ffa 100644 --- a/src/xcb_util.c +++ b/src/xcb_util.c @@ -216,24 +216,3 @@ int _xcb_set_fd_flags(const int fd) return 0; return 1; } - -int _xcb_read_block(const int fd, void *buf, const size_t len) -{ - int done = 0; - while(done < len) - { - int ret = read(fd, ((char *) buf) + done, len - done); - if(ret > 0) - done += ret; - if(ret < 0 && errno == EAGAIN) - { - fd_set fds; - FD_ZERO(&fds); - FD_SET(fd, &fds); - ret = select(fd + 1, &fds, 0, 0, 0); - } - if(ret <= 0) - return ret; - } - return len; -} diff --git a/src/xcbint.h b/src/xcbint.h index 439b885..ae36ac5 100644 --- a/src/xcbint.h +++ b/src/xcbint.h @@ -73,7 +73,6 @@ void *_xcb_map_remove(_xcb_map *q, unsigned int key); #define XCB_PAD(i) (-(i) & 3) int _xcb_set_fd_flags(const int fd); -int _xcb_read_block(const int fd, void *buf, const size_t len); /* xcb_out.c */ |