ust consumer: flag shm/wait fd as copy
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 3 Nov 2011 23:33:24 +0000 (19:33 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 3 Nov 2011 23:33:24 +0000 (19:33 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
include/lttng/lttng-consumer.h
liblttng-consumer/lttng-consumer.c
liblttng-ustconsumer/lttng-ustconsumer.c

index a0277cf042bddd5fc561a31864fceb8e243897bf..7751570efef38cfde7319b97bb3f114381c7b793 100644 (file)
@@ -83,6 +83,8 @@ struct lttng_consumer_channel {
        size_t mmap_len;
        struct lttng_ust_shm_handle *handle;
        int nr_streams;
+       int shm_fd_is_copy;
+       int wait_fd_is_copy;
 };
 
 /* Forward declaration for UST. */
@@ -110,6 +112,8 @@ struct lttng_consumer_stream {
        void *mmap_base;
        size_t mmap_len;
        enum lttng_event_output output; /* splice or mmap */
+       int shm_fd_is_copy;
+       int wait_fd_is_copy;
        /* For UST */
        struct lttng_ust_lib_ring_buffer *buf;
        int cpu;
index 081d6142b2d76505f3f4de4520654380d3c220cc..5311860e01ac3d5c145991c194d3f3a32060d96f 100644 (file)
@@ -125,10 +125,11 @@ void consumer_del_stream(struct lttng_consumer_stream *stream)
        if (stream->out_fd >= 0) {
                close(stream->out_fd);
        }
-       if (stream->wait_fd >= 0) {
+       if (stream->wait_fd >= 0 && !stream->wait_fd_is_copy) {
                close(stream->wait_fd);
        }
-       if (stream->shm_fd >= 0 && stream->wait_fd != stream->shm_fd) {
+       if (stream->shm_fd >= 0 && stream->wait_fd != stream->shm_fd
+                       && !stream->shm_fd_is_copy) {
                close(stream->shm_fd);
        }
        if (!--stream->chan->refcount)
@@ -282,10 +283,11 @@ void consumer_del_channel(struct lttng_consumer_channel *channel)
                        perror("munmap");
                }
        }
-       if (channel->wait_fd >= 0) {
+       if (channel->wait_fd >= 0 && !channel->wait_fd_is_copy) {
                close(channel->wait_fd);
        }
-       if (channel->shm_fd >= 0 && channel->wait_fd != channel->shm_fd) {
+       if (channel->shm_fd >= 0 && channel->wait_fd != channel->shm_fd
+                       && !channel->shm_fd_is_copy) {
                close(channel->shm_fd);
        }
        free(channel);
index bf3ae08452f9371afc08393b6ba56c4f71e1c541..db0ba05bd6a160c691b77eff6fe8808a2032dd45 100644 (file)
@@ -272,11 +272,11 @@ int lttng_ustconsumer_allocate_channel(struct lttng_consumer_channel *chan)
                return -ENOMEM;
        }
        /*
-        * The channel shm and wait fds are passed to ustctl, set them
-        * to -1 here.
+        * The channel fds are passed to ustctl, we only keep a copy.
         */
-       chan->shm_fd = -1;
-       chan->wait_fd = -1;
+       chan->shm_fd_is_copy = 1;
+       chan->wait_fd_is_copy = 1;
+
        return 0;
 }
 
@@ -305,11 +305,10 @@ int lttng_ustconsumer_allocate_stream(struct lttng_consumer_stream *stream)
                return -EINVAL;
        }
        /*
-        * The stream shm and wait fds are passed to ustctl, set them to
-        * -1 here.
+        * The stream fds are passed to ustctl, we only keep a copy.
         */
-       stream->shm_fd = -1;
-       stream->wait_fd = -1;
+       stream->shm_fd_is_copy = 1;
+       stream->wait_fd_is_copy = 1;
 
        return 0;
 }
This page took 0.027381 seconds and 4 git commands to generate.