[Xcb] [PATCH] Handle EAGAIN errno from poll(2) or select(2)

Jeremy Huddleston Sequoia jeremyhu at apple.com
Wed Aug 19 16:09:33 PDT 2015


No known fallout from this, but I spotted the possible issue when auditing
this code to track down a related issue.  While not noted in SUS, some
implementations (like darwin) may return EAGAIN for (possibly) transient
kernel issues that would suggest trying again.

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
---
 src/xcb_conn.c | 2 +-
 src/xcb_in.c   | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/xcb_conn.c b/src/xcb_conn.c
index 7d09637..7e49384 100644
--- a/src/xcb_conn.c
+++ b/src/xcb_conn.c
@@ -487,7 +487,7 @@ int _xcb_conn_wait(xcb_connection_t *c, pthread_cond_t *cond, struct iovec **vec
 #else
         ret = select(c->fd + 1, &rfds, &wfds, 0, 0);
 #endif
-    } while (ret == -1 && errno == EINTR);
+    } while (ret == -1 && (errno == EINTR || errno == EAGAIN));
     if(ret < 0)
     {
         _xcb_conn_shutdown(c, XCB_CONN_ERROR);
diff --git a/src/xcb_in.c b/src/xcb_in.c
index bab4bc7..e806388 100644
--- a/src/xcb_in.c
+++ b/src/xcb_in.c
@@ -386,7 +386,7 @@ static int read_block(const int fd, void *buf, const ssize_t len)
             pfd.revents = 0;
             do {
                 ret = poll(&pfd, 1, -1);
-            } while (ret == -1 && errno == EINTR);
+            } while (ret == -1 && (errno == EINTR || errno == EAGAIN));
 #else
             fd_set fds;
             FD_ZERO(&fds);
@@ -396,7 +396,7 @@ static int read_block(const int fd, void *buf, const ssize_t len)
             errno = 0;
             do {
                 ret = select(fd + 1, &fds, 0, 0, 0);
-            } while (ret == -1 && errno == EINTR);
+            } while (ret == -1 && (errno == EINTR || errno == EAGAIN));
 #endif /* USE_POLL */
         }
         if(ret <= 0)
-- 
2.5.0



More information about the Xcb mailing list