From: Mathieu Desnoyers Date: Thu, 12 Jan 2012 19:30:04 +0000 (-0500) Subject: UST consumer: close shm fd after mapping it X-Git-Tag: v2.0-pre17~22^2~2 X-Git-Url: https://git.liburcu.org/?a=commitdiff_plain;h=2c1dd183d5e75a133090c65ecb4ff326981b3ad9;hp=18cef8030188c29b1eb5a251e1c0de58b24e40b1;p=lttng-tools.git UST consumer: close shm fd after mapping it Signed-off-by: Mathieu Desnoyers --- diff --git a/include/lttng/lttng-consumer.h b/include/lttng/lttng-consumer.h index f5ad3e6f2..3d16d4973 100644 --- a/include/lttng/lttng-consumer.h +++ b/include/lttng/lttng-consumer.h @@ -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; }; diff --git a/liblttng-consumer/lttng-consumer.c b/liblttng-consumer/lttng-consumer.c index 5a4cf08c5..0263aa1d8 100644 --- a/liblttng-consumer/lttng-consumer.c +++ b/liblttng-consumer/lttng-consumer.c @@ -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); diff --git a/liblttng-ustconsumer/lttng-ustconsumer.c b/liblttng-ustconsumer/lttng-ustconsumer.c index 26e680a9c..8305b061a 100644 --- a/liblttng-ustconsumer/lttng-ustconsumer.c +++ b/liblttng-ustconsumer/lttng-ustconsumer.c @@ -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; }