Fix: free metadata cache after grace period in consumer
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sun, 23 Aug 2015 02:58:09 +0000 (19:58 -0700)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 8 Sep 2015 13:10:46 +0000 (09:10 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/common/consumer.c
src/common/ust-consumer/ust-consumer.c
src/common/ust-consumer/ust-consumer.h

index 526fbbf35c157f2bf545ef53b68dc0e45ef17365..f2ccf9536b147b72574638046135da3e425b771a 100644 (file)
@@ -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);
 }
 
index 7dfcf9a3cf46381675222dfbcb94a474e0e8eaa9..d45707b763deaf653b3ed75f65c80a3f5ed42b55 100644 (file)
@@ -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);
index 4357380a60965855d36fe199d9cf7c68eb446e5b..08f1fa8a33bef09b81632fcfe4fed5df6325da4e 100644 (file)
@@ -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)
 {
This page took 0.029687 seconds and 4 git commands to generate.