From: Mathieu Desnoyers Date: Sun, 23 Aug 2015 02:58:09 +0000 (-0700) Subject: Fix: free metadata cache after grace period in consumer X-Git-Tag: v2.8.0-rc1~427 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=b83e03c499;p=lttng-tools.git Fix: free metadata cache after grace period in consumer Signed-off-by: Mathieu Desnoyers Signed-off-by: Jérémie Galarneau --- 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) {