UST consumer: close shm fd after mapping it
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 12 Jan 2012 19:30:04 +0000 (14:30 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 12 Jan 2012 19:30:04 +0000 (14:30 -0500)
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 f5ad3e6f2ad416d5e3d6064444d1064ff1caa519..3d16d49732f9175a68ecff669e0ace402d55b2c2 100644 (file)
@@ -78,7 +78,6 @@ 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;
        int cpucount;
 };
index 5a4cf08c59109a7a5f21d8cc8070eb699debd3e0..0263aa1d83134bb5edd2937effce7d9cec1e4320 100644 (file)
@@ -178,8 +178,7 @@ void consumer_del_stream(struct lttng_consumer_stream *stream)
        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
-                       && !stream->shm_fd_is_copy) {
+       if (stream->shm_fd >= 0 && stream->wait_fd != stream->shm_fd) {
                close(stream->shm_fd);
        }
        if (!--stream->chan->refcount)
@@ -363,8 +362,7 @@ void consumer_del_channel(struct lttng_consumer_channel *channel)
        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
-                       && !channel->shm_fd_is_copy) {
+       if (channel->shm_fd >= 0 && channel->wait_fd != channel->shm_fd) {
                close(channel->shm_fd);
        }
        free(channel);
index 26e680a9cd757d6bc5974dda20d6a30df3ccb9b2..8305b061a882fff9021037e1716ff32fb3f36935 100644 (file)
@@ -278,11 +278,8 @@ int lttng_ustconsumer_allocate_channel(struct lttng_consumer_channel *chan)
        if (!chan->handle) {
                return -ENOMEM;
        }
-       /*
-        * The channel fds are passed to ustctl, we only keep a copy.
-        */
-       chan->shm_fd_is_copy = 1;
        chan->wait_fd_is_copy = 1;
+       chan->shm_fd = -1;
 
        return 0;
 }
@@ -313,15 +310,14 @@ int lttng_ustconsumer_allocate_stream(struct lttng_consumer_stream *stream)
        stream->buf = ustctl_open_stream_read(stream->chan->handle, stream->cpu);
        if (!stream->buf)
                return -EBUSY;
+       /* ustctl_open_stream_read has closed the shm fd. */
+       stream->wait_fd_is_copy = 1;
+       stream->shm_fd = -1;
+
        stream->mmap_base = ustctl_get_mmap_base(stream->chan->handle, stream->buf);
        if (!stream->mmap_base) {
                return -EINVAL;
        }
-       /*
-        * The stream fds are passed to ustctl, we only keep a copy.
-        */
-       stream->shm_fd_is_copy = 1;
-       stream->wait_fd_is_copy = 1;
 
        return 0;
 }
This page took 0.031494 seconds and 4 git commands to generate.