From: Mathieu Desnoyers Date: Wed, 27 Apr 2016 20:28:02 +0000 (-0400) Subject: Fix: free ust channel object after grace period in consumer X-Git-Tag: v2.6.3~65 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=4534c65b3354b8f93cd7e9610953495b1d6cc7f3;p=lttng-tools.git Fix: free ust channel object after grace period in consumer [ Backport from master branch commit b83e03c499 "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 2dd31ffd6..9a3bf86e7 100644 --- a/src/common/consumer.c +++ b/src/common/consumer.c @@ -285,6 +285,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 28b7f10a6..152455ca6 100644 --- a/src/common/ust-consumer/ust-consumer.c +++ b/src/common/ust-consumer/ust-consumer.c @@ -79,6 +79,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); } @@ -1687,6 +1688,13 @@ void lttng_ustconsumer_del_channel(struct lttng_consumer_channel *chan) if (chan->switch_timer_enabled == 1) { consumer_timer_switch_stop(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); } 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) {