X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fust-registry.c;h=1a00e9349fb2f04c6052a5222acaf7d927fdd471;hp=8c3d08d825c5568255ece6295d0b6be1dc2aa2a4;hb=90e7d72ff2b93752b8c81c49e9251a83b01703c6;hpb=d24ff3fdbdeb795bfde99e499fe75427cbe4f5d7 diff --git a/src/bin/lttng-sessiond/ust-registry.c b/src/bin/lttng-sessiond/ust-registry.c index 8c3d08d82..1a00e9349 100644 --- a/src/bin/lttng-sessiond/ust-registry.c +++ b/src/bin/lttng-sessiond/ust-registry.c @@ -15,6 +15,7 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #define _GNU_SOURCE +#define _LGPL_SOURCE #include #include @@ -607,20 +608,27 @@ void ust_registry_session_destroy(struct ust_registry_session *reg) struct lttng_ht_iter iter; struct ust_registry_channel *chan; + if (!reg) { + return; + } + /* On error, EBUSY can be returned if lock. Code flow error. */ ret = pthread_mutex_destroy(®->lock); assert(!ret); - rcu_read_lock(); - /* Destroy all event associated with this registry. */ - cds_lfht_for_each_entry(reg->channels->ht, &iter.iter, chan, node.node) { - /* Delete the node from the ht and free it. */ - ret = lttng_ht_del(reg->channels, &iter); - assert(!ret); - destroy_channel(chan); + if (reg->channels) { + rcu_read_lock(); + /* Destroy all event associated with this registry. */ + cds_lfht_for_each_entry(reg->channels->ht, &iter.iter, chan, + node.node) { + /* Delete the node from the ht and free it. */ + ret = lttng_ht_del(reg->channels, &iter); + assert(!ret); + destroy_channel(chan); + } + rcu_read_unlock(); + ht_cleanup_push(reg->channels); } - rcu_read_unlock(); - ht_cleanup_push(reg->channels); free(reg->metadata); }