From: David Goulet Date: Thu, 16 May 2013 15:30:15 +0000 (-0400) Subject: Fix: epoll attributes used outside of compat layer X-Git-Tag: v2.2.0-rc3~60 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=6d737ce48af40e77ca27cb78348e7f3042eab3ed;p=lttng-tools.git Fix: epoll attributes used outside of compat layer This was breaking the poll() support. A lttng_poll_init is added which basically resets the lttng poll event data structure and in the case of epoll sets the epfd to -1. Signed-off-by: David Goulet --- diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index 6f9834425..f6e7094bf 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -705,9 +705,9 @@ static void *thread_manage_kernel(void *data) /* * This first step of the while is to clean this structure which could free - * non NULL pointers so zero it before the loop. + * non NULL pointers so initialize it before the loop. */ - memset(&events, 0, sizeof(events)); + lttng_poll_init(&events); if (testpoint(thread_manage_kernel)) { goto error_testpoint; @@ -3108,9 +3108,8 @@ static void *thread_manage_health(void *data) rcu_register_thread(); - /* We might hit an error path before this is set once. */ - memset(&events, 0, sizeof(events)); - events.epfd = -1; + /* We might hit an error path before this is created. */ + lttng_poll_init(&events); /* Create unix socket */ sock = lttcomm_create_unix_sock(health_unix_sock_path); diff --git a/src/common/compat/poll.h b/src/common/compat/poll.h index e69d59b42..8403880cf 100644 --- a/src/common/compat/poll.h +++ b/src/common/compat/poll.h @@ -158,6 +158,17 @@ static inline void lttng_poll_reset(struct lttng_poll_event *events) } } +/* + * Initialize an already allocated poll event data structure. For epoll(), the + * epfd is set to -1 to indicate that it's not usable. + */ +static inline void lttng_poll_init(struct lttng_poll_event *events) +{ + lttng_poll_reset(events); + /* Set fd to -1 so if clean before created, we don't close 0. */ + events->epfd = -1; +} + /* * Clean the events structure of a lttng_poll_event. It's the caller * responsability to free the lttng_poll_event memory. @@ -317,6 +328,14 @@ extern void compat_poll_set_max_size(void); static inline void lttng_poll_reset(struct lttng_poll_event *events) {} +/* + * Initialize an already allocated poll event data structure. + */ +static inline void lttng_poll_init(struct lttng_poll_event *events) +{ + memset(events, 0, sizeof(struct lttng_poll_event)); +} + /* * Clean the events structure of a lttng_poll_event. It's the caller * responsability to free the lttng_poll_event memory.