diff options
author | Michael Ost <most@museresearch.com> | 2009-03-30 11:09:32 +0200 |
---|---|---|
committer | Julien Danjou <julien@danjou.info> | 2009-03-30 11:09:32 +0200 |
commit | f916062edf0e04cd4e0a78f6975892f59fae3b60 (patch) | |
tree | 990c261bc6ea3bed19185264e6fec98624ed3e53 /src/xcb_in.c | |
parent | beccb0be15f5699c942a0af33307d9e4bf797e2a (diff) |
use poll() instead of select() when available
Signed-off-by: Julien Danjou <julien@danjou.info>
Diffstat (limited to 'src/xcb_in.c')
-rw-r--r-- | src/xcb_in.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/xcb_in.c b/src/xcb_in.c index 212dc9a..26ab358 100644 --- a/src/xcb_in.c +++ b/src/xcb_in.c @@ -30,12 +30,16 @@ #include <stdlib.h> #include <unistd.h> #include <stdio.h> -#include <sys/select.h> #include <errno.h> #include "xcb.h" #include "xcbext.h" #include "xcbint.h" +#if USE_POLL +#include <poll.h> +#else +#include <sys/select.h> +#endif #define XCB_ERROR 0 #define XCB_REPLY 1 @@ -268,12 +272,22 @@ static int read_block(const int fd, void *buf, const ssize_t len) done += ret; if(ret < 0 && errno == EAGAIN) { +#if USE_POLL + struct pollfd pfd; + pfd.fd = fd; + pfd.events = POLLIN; + pfd.revents = 0; + do { + ret = poll(&pfd, 1, -1); + } while (ret == -1 && errno == EINTR); +#else fd_set fds; FD_ZERO(&fds); FD_SET(fd, &fds); do { ret = select(fd + 1, &fds, 0, 0, 0); } while (ret == -1 && errno == EINTR); +#endif } if(ret <= 0) return ret; |