X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fust-registry.c;h=b538a8fa9f37d6f5108c609a3021a27173cbe9ac;hp=19cff09fcd9d26aedb4a79194d10f7875e5fc810;hb=3a1aff7a271016fa0104e45492ca94e7e06b2492;hpb=7972aab22f74b18faa168c0482216a3dd711a075 diff --git a/src/bin/lttng-sessiond/ust-registry.c b/src/bin/lttng-sessiond/ust-registry.c index 19cff09fc..b538a8fa9 100644 --- a/src/bin/lttng-sessiond/ust-registry.c +++ b/src/bin/lttng-sessiond/ust-registry.c @@ -313,7 +313,7 @@ void ust_registry_destroy_event(struct ust_registry_channel *chan, * free the registry pointer since it might not have been allocated before so * it's the caller responsability. * - * This MUST be called within a RCU read side lock section. + * This *MUST NOT* be called within a RCU read side lock section. */ static void destroy_channel(struct ust_registry_channel *chan) { @@ -322,13 +322,15 @@ static void destroy_channel(struct ust_registry_channel *chan) assert(chan); + rcu_read_lock(); /* Destroy all event associated with this registry. */ cds_lfht_for_each_entry(chan->ht->ht, &iter.iter, event, node.node) { /* Delete the node from the ht and free it. */ ust_registry_destroy_event(chan, event); } - lttng_ht_destroy(chan->ht); + rcu_read_unlock(); + lttng_ht_destroy(chan->ht); free(chan); } @@ -418,22 +420,30 @@ void ust_registry_channel_del_free(struct ust_registry_session *session, { struct lttng_ht_iter iter; struct ust_registry_channel *chan; + int ret; assert(session); rcu_read_lock(); chan = ust_registry_channel_find(session, key); if (!chan) { + rcu_read_unlock(); goto end; } iter.iter.node = &chan->node.node; - lttng_ht_del(session->channels, &iter); + ret = lttng_ht_del(session->channels, &iter); + assert(!ret); + rcu_read_unlock(); + /* + * Destroying the hash table should be done without RCU + * read-side lock held. Since we own "chan" now, it is OK to use + * it outside of RCU read-side critical section. + */ destroy_channel(chan); end: - rcu_read_unlock(); return; } @@ -452,13 +462,14 @@ int ust_registry_session_init(struct ust_registry_session **sessionp, uint32_t uint32_t_alignment, uint32_t uint64_t_alignment, uint32_t long_alignment, - int byte_order) + int byte_order, + uint32_t major, + uint32_t minor) { int ret; struct ust_registry_session *session; assert(sessionp); - assert(app); session = zmalloc(sizeof(*session)); if (!session) { @@ -487,7 +498,7 @@ int ust_registry_session_init(struct ust_registry_session **sessionp, } pthread_mutex_lock(&session->lock); - ret = ust_metadata_session_statedump(session, app); + ret = ust_metadata_session_statedump(session, app, major, minor); pthread_mutex_unlock(&session->lock); if (ret) { ERR("Failed to generate session metadata (errno = %d)", ret);