Fix: epoll attributes used outside of compat layer
authorDavid Goulet <dgoulet@efficios.com>
Thu, 16 May 2013 15:30:15 +0000 (11:30 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Thu, 16 May 2013 15:41:32 +0000 (11:41 -0400)
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 <dgoulet@efficios.com>
src/bin/lttng-sessiond/main.c
src/common/compat/poll.h

index 6f9834425192c3ca4b1f9f0e184071eb87f68b87..f6e7094bfca08947c3cddb5d1693818a350ee5dc 100644 (file)
@@ -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);
index e69d59b42d054efbc900fd5412db093362fc5190..8403880cf3742c61f4c01e281a69f2f5ff9084db 100644 (file)
@@ -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.
This page took 0.028328 seconds and 4 git commands to generate.