From: David Goulet Date: Tue, 13 Mar 2012 21:14:17 +0000 (-0400) Subject: Fix consumer CPU hotplug support X-Git-Tag: v2.0.0-rc3~4 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=c77fc10ab0bfcf974836c30da4929e431064b8b3;p=lttng-tools.git Fix consumer CPU hotplug support This is a quick fix to handle stream update on CPU hotplug. Please look at #ref 168 for more information and explanation on the real fix. Signed-off-by: David Goulet --- diff --git a/src/common/consumer.c b/src/common/consumer.c index d68bc5c27..f81de8d55 100644 --- a/src/common/consumer.c +++ b/src/common/consumer.c @@ -298,11 +298,23 @@ end: int consumer_add_stream(struct lttng_consumer_stream *stream) { int ret = 0; + struct lttng_ht_node_ulong *node; + struct lttng_ht_iter iter; pthread_mutex_lock(&consumer_data.lock); /* Steal stream identifier, for UST */ consumer_steal_stream_key(stream->key); rcu_read_lock(); + + lttng_ht_lookup(consumer_data.stream_ht, + (void *)((unsigned long) stream->key), &iter); + node = lttng_ht_iter_get_node_ulong(&iter); + if (node != NULL) { + rcu_read_unlock(); + /* Stream already exist. Ignore the insertion */ + goto end; + } + lttng_ht_add_unique_ulong(consumer_data.stream_ht, &stream->node); rcu_read_unlock(); consumer_data.stream_count++; @@ -466,11 +478,25 @@ end: */ int consumer_add_channel(struct lttng_consumer_channel *channel) { + struct lttng_ht_node_ulong *node; + struct lttng_ht_iter iter; + pthread_mutex_lock(&consumer_data.lock); /* Steal channel identifier, for UST */ consumer_steal_channel_key(channel->key); rcu_read_lock(); + + lttng_ht_lookup(consumer_data.channel_ht, + (void *)((unsigned long) channel->key), &iter); + node = lttng_ht_iter_get_node_ulong(&iter); + if (node != NULL) { + /* Channel already exist. Ignore the insertion */ + goto end; + } + lttng_ht_add_unique_ulong(consumer_data.channel_ht, &channel->node); + +end: rcu_read_unlock(); pthread_mutex_unlock(&consumer_data.lock);