summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/xcb_in.c11
-rw-r--r--src/xcb_util.c12
-rw-r--r--src/xcbint.h1
3 files changed, 13 insertions, 11 deletions
diff --git a/src/xcb_in.c b/src/xcb_in.c
index 967beac..4a62a48 100644
--- a/src/xcb_in.c
+++ b/src/xcb_in.c
@@ -28,6 +28,7 @@
#include <assert.h>
#include <string.h>
#include <stdlib.h>
+#include <unistd.h>
#include <stdio.h>
#include <errno.h>
@@ -68,6 +69,14 @@ static void wake_up_next_reader(XCBConnection *c)
assert(pthreadret == 0);
}
+static int readn(const int fd, void *buf, const int buflen, int *count)
+{
+ int n = read(fd, ((char *) buf) + *count, buflen - *count);
+ if(n > 0)
+ *count += n;
+ return n;
+}
+
static int read_packet(XCBConnection *c)
{
XCBGenericRep genrep;
@@ -327,7 +336,7 @@ int _xcb_in_expect_reply(XCBConnection *c, unsigned int request, enum workaround
int _xcb_in_read(XCBConnection *c)
{
- int n = _xcb_readn(c->fd, c->in.queue, sizeof(c->in.queue), &c->in.queue_len);
+ int n = readn(c->fd, c->in.queue, sizeof(c->in.queue), &c->in.queue_len);
while(read_packet(c))
/* empty */;
return (n > 0) || (n < 0 && errno == EAGAIN);
diff --git a/src/xcb_util.c b/src/xcb_util.c
index db3bffb..c9c7f92 100644
--- a/src/xcb_util.c
+++ b/src/xcb_util.c
@@ -217,20 +217,14 @@ int _xcb_set_fd_flags(const int fd)
return 1;
}
-int _xcb_readn(const int fd, void *buf, const int buflen, int *count)
-{
- int n = read(fd, ((char *) buf) + *count, buflen - *count);
- if(n > 0)
- *count += n;
- return n;
-}
-
int _xcb_read_block(const int fd, void *buf, const size_t len)
{
int done = 0;
while(done < len)
{
- int ret = _xcb_readn(fd, buf, len, &done);
+ int ret = read(fd, ((char *) buf) + done, len - done);
+ if(ret > 0)
+ done += ret;
if(ret < 0 && errno == EAGAIN)
{
fd_set fds;
diff --git a/src/xcbint.h b/src/xcbint.h
index e7e6688..ebbb2fe 100644
--- a/src/xcbint.h
+++ b/src/xcbint.h
@@ -72,7 +72,6 @@ void *_xcb_map_remove(_xcb_map *q, unsigned int key);
#define XCB_PAD(i) ((4 - (i & 3)) & 3)
int _xcb_set_fd_flags(const int fd);
-int _xcb_readn(const int fd, void *buf, const int buflen, int *count);
int _xcb_read_block(const int fd, void *buf, const size_t len);