From: David Goulet Date: Mon, 10 Dec 2012 21:03:58 +0000 (-0500) Subject: Fix: Use stream deletion function when cleaning up X-Git-Tag: v2.1.0~69 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=5c540210ba9c26bd5de0ea135c872d3807d5bb4b;p=lttng-tools.git 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 --- 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();