Introduce channel timer lock
[lttng-tools.git] / src / common / ust-consumer / ust-consumer.c
index 21d7050b6761c1ebff8f0721f2e64379c68d06e5..61b220ee012a76930d3149be0eba07ba2fef919b 100644 (file)
@@ -550,43 +550,6 @@ error:
        return ret;
 }
 
-/*
- * Write metadata to the given channel using ustctl to convert the string to
- * the ringbuffer.
- * Called only from consumer_metadata_cache_write.
- * The metadata cache lock MUST be acquired to write in the cache.
- *
- * Return 0 on success else a negative value.
- */
-int lttng_ustconsumer_push_metadata(struct lttng_consumer_channel *metadata,
-               const char *metadata_str, uint64_t target_offset, uint64_t len)
-{
-       int ret;
-
-       assert(metadata);
-       assert(metadata_str);
-
-       DBG("UST consumer writing metadata to channel %s", metadata->name);
-
-       if (!metadata->metadata_stream) {
-               ret = 0;
-               goto error;
-       }
-
-       assert(target_offset <= metadata->metadata_cache->max_offset);
-       ret = ustctl_write_metadata_to_channel(metadata->uchan,
-                       metadata_str + target_offset, len);
-       if (ret < 0) {
-               ERR("ustctl write metadata fail with ret %d, len %" PRIu64, ret, len);
-               goto error;
-       }
-
-       ustctl_flush_buffer(metadata->metadata_stream->ustream, 1);
-
-error:
-       return ret;
-}
-
 /*
  * Flush channel's streams using the given key to retrieve the channel.
  *
@@ -651,6 +614,7 @@ static int close_metadata(uint64_t chan_key)
 
        pthread_mutex_lock(&consumer_data.lock);
        pthread_mutex_lock(&channel->lock);
+       pthread_mutex_lock(&channel->timer_lock);
 
        if (cds_lfht_is_node_deleted(&channel->node.node)) {
                goto error_unlock;
@@ -678,6 +642,7 @@ static int close_metadata(uint64_t chan_key)
        }
 
 error_unlock:
+       pthread_mutex_unlock(&channel->timer_lock);
        pthread_mutex_unlock(&channel->lock);
        pthread_mutex_unlock(&consumer_data.lock);
 error:
@@ -1841,6 +1806,12 @@ void lttng_ustconsumer_close_stream_wakeup(struct lttng_consumer_stream *stream)
        }
 }
 
+/*
+ * Please refer to consumer-timer.c before adding any lock within this
+ * function or any of its callees. Timers have a very strict locking
+ * semantic with respect to teardown. Failure to respect this semantic
+ * introduces deadlocks.
+ */
 int lttng_ustconsumer_request_metadata(struct lttng_consumer_local_data *ctx,
                struct lttng_consumer_channel *channel)
 {
This page took 0.023373 seconds and 4 git commands to generate.