From 11544fe515a052531f84dffcc0a59a7388277d40 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Sat, 22 Aug 2015 19:58:09 -0700 Subject: [PATCH] Fix: free metadata cache after grace period in consumer MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Mathieu Desnoyers Signed-off-by: Jérémie Galarneau --- src/common/consumer.c | 11 +++++++++++ src/common/ust-consumer/ust-consumer.c | 14 +++++++++++--- src/common/ust-consumer/ust-consumer.h | 6 ++++++ 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/common/consumer.c b/src/common/consumer.c index 526fbbf35..f2ccf9536 100644 --- a/src/common/consumer.c +++ b/src/common/consumer.c @@ -286,6 +286,17 @@ static void free_channel_rcu(struct rcu_head *head) struct lttng_consumer_channel *channel = caa_container_of(node, struct lttng_consumer_channel, node); + switch (consumer_data.type) { + case LTTNG_CONSUMER_KERNEL: + break; + case LTTNG_CONSUMER32_UST: + case LTTNG_CONSUMER64_UST: + lttng_ustconsumer_free_channel(channel); + break; + default: + ERR("Unknown consumer_data type"); + abort(); + } free(channel); } diff --git a/src/common/ust-consumer/ust-consumer.c b/src/common/ust-consumer/ust-consumer.c index 7dfcf9a3c..d45707b76 100644 --- a/src/common/ust-consumer/ust-consumer.c +++ b/src/common/ust-consumer/ust-consumer.c @@ -82,6 +82,7 @@ static void destroy_channel(struct lttng_consumer_channel *channel) */ if (channel->uchan) { lttng_ustconsumer_del_channel(channel); + lttng_ustconsumer_free_channel(channel); } free(channel); } @@ -1830,8 +1831,6 @@ void lttng_ustconsumer_del_channel(struct lttng_consumer_channel *chan) if (chan->switch_timer_enabled == 1) { consumer_timer_switch_stop(chan); } - consumer_metadata_cache_destroy(chan); - ustctl_destroy_channel(chan->uchan); for (i = 0; i < chan->nr_stream_fds; i++) { int ret; @@ -1852,7 +1851,6 @@ void lttng_ustconsumer_del_channel(struct lttng_consumer_channel *chan) } } } - free(chan->stream_fds); /* Try to rmdir all directories under shm_path root. */ if (chan->root_shm_path[0]) { (void) run_as_recursive_rmdir(chan->root_shm_path, @@ -1860,6 +1858,16 @@ void lttng_ustconsumer_del_channel(struct lttng_consumer_channel *chan) } } +void lttng_ustconsumer_free_channel(struct lttng_consumer_channel *chan) +{ + assert(chan); + assert(chan->uchan); + + consumer_metadata_cache_destroy(chan); + ustctl_destroy_channel(chan->uchan); + free(chan->stream_fds); +} + void lttng_ustconsumer_del_stream(struct lttng_consumer_stream *stream) { assert(stream); diff --git a/src/common/ust-consumer/ust-consumer.h b/src/common/ust-consumer/ust-consumer.h index 4357380a6..08f1fa8a3 100644 --- a/src/common/ust-consumer/ust-consumer.h +++ b/src/common/ust-consumer/ust-consumer.h @@ -38,6 +38,7 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, extern int lttng_ustconsumer_allocate_channel(struct lttng_consumer_channel *chan); extern void lttng_ustconsumer_del_channel(struct lttng_consumer_channel *chan); +extern void lttng_ustconsumer_free_channel(struct lttng_consumer_channel *chan); extern int lttng_ustconsumer_add_stream(struct lttng_consumer_stream *stream); extern void lttng_ustconsumer_del_stream(struct lttng_consumer_stream *stream); @@ -119,6 +120,11 @@ void lttng_ustconsumer_del_channel(struct lttng_consumer_channel *chan) { } +static inline +void lttng_ustconsumer_free_channel(struct lttng_consumer_channel *chan) +{ +} + static inline int lttng_ustconsumer_add_stream(struct lttng_consumer_stream *stream) { -- 2.34.1