[Xcb] [PATCH] Handle EAGAIN errno from poll(2) or select(2)
Mark Kettenis
mark.kettenis at xs4all.nl
Wed Aug 19 23:59:19 PDT 2015
> From: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
> Date: Wed, 19 Aug 2015 16:09:33 -0700
>
> 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.
Well, EAGAIN suggests "try again *later*". Presumably the kernel
would return EAGAIN immediately and therefore this change may very
well introduce a spinning loop. That would not be good, and I'd say
returning an error would be preferable over having the application
spin.
Having the kernel return EAGAIN for a blocking poll or select would be
a serious bug IMHB. It should just wait until resources are
available. Does Darwin really have such a bug, or are you just trying
to strike pre-emptively?
> 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
>
> _______________________________________________
> Xcb mailing list
> Xcb at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/xcb
>
>
More information about the Xcb
mailing list