Fix: incorrect close of fd 0 for syscall kernel event destroy
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 2 Mar 2012 16:54:13 +0000 (11:54 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 2 Mar 2012 16:54:13 +0000 (11:54 -0500)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
src/bin/lttng-sessiond/kernel.c
src/bin/lttng-sessiond/trace-kernel.c

index 371ee4f98a998a3639170ebde6cc8d7142056e94..2936406d84f704d1a293e95dd21f248e5c5660b3 100644 (file)
@@ -208,6 +208,11 @@ int kernel_create_event(struct lttng_event *ev,
         */
        if (ret == 0 && event->event->instrumentation == LTTNG_KERNEL_SYSCALL) {
                DBG2("Kernel event syscall creation success");
+               /*
+                * We use fd == -1 to ensure that we never trigger a close of fd
+                * 0.
+                */
+               event->fd = -1;
                goto add_list;
        }
 
index 36f7c9708a8f47e0fa33d9ce579a33c0bf607e08..68753286fb81c336e5026eb0eb64411ebbd5a81f 100644 (file)
@@ -321,9 +321,13 @@ void trace_kernel_destroy_stream(struct ltt_kernel_stream *stream)
  */
 void trace_kernel_destroy_event(struct ltt_kernel_event *event)
 {
-       DBG("[trace] Closing event fd %d", event->fd);
-       /* Close kernel fd */
-       close(event->fd);
+       if (event->fd >= 0) {
+               DBG("[trace] Closing event fd %d", event->fd);
+               /* Close kernel fd */
+               close(event->fd);
+       } else {
+               DBG("[trace] Tearing down event (no associated fd)");
+       }
 
        /* Remove from event list */
        cds_list_del(&event->list);
This page took 0.035786 seconds and 4 git commands to generate.