From 5c540210ba9c26bd5de0ea135c872d3807d5bb4b Mon Sep 17 00:00:00 2001 From: David Goulet Date: Mon, 10 Dec 2012 16:03:58 -0500 Subject: [PATCH] Fix: Use stream deletion function when cleaning up In theory, once the destroy stream ht function is called with the hash table, it should be empty. However, for some fatal errors, it might not so it's imperative that we gracefully delete the stream and free it using an RCU call so both hash tables (stream and the one for the pending command) are synchronized. Simply freeing the stream could have created possible fd leaks and invalid node for the data pending hash table. Signed-off-by: David Goulet --- src/common/consumer.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/common/consumer.c b/src/common/consumer.c index 5766860a8..ec73a0add 100644 --- a/src/common/consumer.c +++ b/src/common/consumer.c @@ -764,6 +764,8 @@ void consumer_del_channel(struct lttng_consumer_channel *channel) int ret; struct lttng_ht_iter iter; + DBG("Consumer delete channel key %d", channel->key); + pthread_mutex_lock(&consumer_data.lock); switch (consumer_data.type) { @@ -1695,7 +1697,6 @@ int lttng_consumer_recv_cmd(struct lttng_consumer_local_data *ctx, */ static void destroy_data_stream_ht(struct lttng_ht *ht) { - int ret; struct lttng_ht_iter iter; struct lttng_consumer_stream *stream; @@ -1705,10 +1706,11 @@ static void destroy_data_stream_ht(struct lttng_ht *ht) rcu_read_lock(); cds_lfht_for_each_entry(ht->ht, &iter.iter, stream, node.node) { - ret = lttng_ht_del(ht, &iter); - assert(!ret); - - call_rcu(&stream->node.head, consumer_free_stream); + /* + * Ignore return value since we are currently cleaning up so any error + * can't be handled. + */ + (void) consumer_del_stream(stream, ht); } rcu_read_unlock(); @@ -1722,7 +1724,6 @@ static void destroy_data_stream_ht(struct lttng_ht *ht) */ static void destroy_stream_ht(struct lttng_ht *ht) { - int ret; struct lttng_ht_iter iter; struct lttng_consumer_stream *stream; @@ -1732,10 +1733,11 @@ static void destroy_stream_ht(struct lttng_ht *ht) rcu_read_lock(); cds_lfht_for_each_entry(ht->ht, &iter.iter, stream, node.node) { - ret = lttng_ht_del(ht, &iter); - assert(!ret); - - call_rcu(&stream->node.head, consumer_free_stream); + /* + * Ignore return value since we are currently cleaning up so any error + * can't be handled. + */ + (void) consumer_del_metadata_stream(stream, ht); } rcu_read_unlock(); -- 2.34.1