From: David Goulet Date: Mon, 17 Dec 2012 17:19:56 +0000 (-0500) Subject: Fix: force the poll() return value to be nb_fd X-Git-Tag: v2.1.0~39 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=9ddba5259d1cb5f9f5ef03ea1e3276082c7e6b80;p=lttng-tools.git Fix: force the poll() return value to be nb_fd With poll(), we have to iterate over all fd in the pollset since it is handled in user space where we don't have to with epoll.o This is a first patch to fix the fact that we should iterate over the number of fd the lttng_poll_wait() call returns which is for epoll the number of returned events and with poll the whole set of fd. Acked-by: Mathieu Desnoyers Signed-off-by: David Goulet --- diff --git a/src/common/compat/compat-epoll.c b/src/common/compat/compat-epoll.c index 939aaace3..e1672c4c3 100644 --- a/src/common/compat/compat-epoll.c +++ b/src/common/compat/compat-epoll.c @@ -188,6 +188,10 @@ int compat_epoll_wait(struct lttng_poll_event *events, int timeout) goto error; } + /* + * Since the returned events are set sequentially in the "events" structure + * we only need to return the epoll_wait value and iterate over it. + */ return ret; error: diff --git a/src/common/compat/compat-poll.c b/src/common/compat/compat-poll.c index 157a2d79d..bacd96e84 100644 --- a/src/common/compat/compat-poll.c +++ b/src/common/compat/compat-poll.c @@ -164,7 +164,11 @@ int compat_poll_wait(struct lttng_poll_event *events, int timeout) goto error; } - return ret; + /* + * poll() should always iterate on all FDs since we handle the pollset in + * user space and after poll returns, we have to try every fd for a match. + */ + return events->nb_fd; error: return -1;