Clean-up: ust-consumer: simplify metadata cache unlock on error path
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 8 Feb 2021 18:00:56 +0000 (13:00 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 19 Feb 2021 18:48:18 +0000 (13:48 -0500)
The metadata cache lock can be released directly after the call to
consumer_metadata_cache_write() since nothing depends on the cache
being locked after.

This simplifies the unlocking of the metadata cache by removing an
extra "unlock" that is specific to an error path.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ib0151d9640309005dfc83e95efb538e3c4f0df4a

src/common/ust-consumer/ust-consumer.c

index e522de750275e08ff366b27ab31d64407b62b1c2..88520dbe260fbfd14a27d1431b3bc0df616e86e7 100644 (file)
@@ -1317,6 +1317,7 @@ int lttng_ustconsumer_recv_metadata(int sock, uint64_t key, uint64_t offset,
        pthread_mutex_lock(&channel->metadata_cache->lock);
        ret = consumer_metadata_cache_write(channel, offset, len, version,
                        metadata_str);
+       pthread_mutex_unlock(&channel->metadata_cache->lock);
        if (ret < 0) {
                /* Unable to handle metadata. Notify session daemon. */
                ret_code = LTTCOMM_CONSUMERD_ERROR_METADATA;
@@ -1325,10 +1326,8 @@ int lttng_ustconsumer_recv_metadata(int sock, uint64_t key, uint64_t offset,
                 * not have been updated which could create an infinite loop below when
                 * waiting for the metadata cache to be flushed.
                 */
-               pthread_mutex_unlock(&channel->metadata_cache->lock);
                goto end_free;
        }
-       pthread_mutex_unlock(&channel->metadata_cache->lock);
 
        if (!wait) {
                goto end_free;
This page took 0.030455 seconds and 4 git commands to generate.