consumerd: clean-up: stream attribute accessed without locking stream
[lttng-tools.git] / src / common / consumer / consumer-metadata-cache.c
index ac83443a9500856f17230563511bba6270dd00c7..5eee4014265f42566776ea34645a0f08504fbde0 100644 (file)
@@ -89,7 +89,7 @@ void metadata_cache_reset(struct consumer_metadata_cache *cache)
  */
 static
 int metadata_cache_check_version(struct consumer_metadata_cache *cache,
-               struct lttng_consumer_channel *channel, uint64_t version)
+               uint64_t version)
 {
        int ret = 0;
 
@@ -120,10 +120,20 @@ int consumer_metadata_wakeup_pipe(const struct lttng_consumer_channel *channel)
                write_ret = lttng_write(channel->metadata_stream->ust_metadata_poll_pipe[1],
                                &dummy, 1);
                if (write_ret < 1) {
-                       PERROR("Wake-up UST metadata pipe");
-                       ret = -1;
-                       goto end;
-               }
+                       if (errno == EWOULDBLOCK) {
+                               /*
+                                * This is fine, the metadata poll thread
+                                * is having a hard time keeping-up, but
+                                * it will eventually wake-up and consume
+                                * the available data.
+                                */
+                               ret = 0;
+                        } else {
+                               PERROR("Wake-up UST metadata pipe");
+                               ret = -1;
+                               goto end;
+                        }
+                }
        }
 
 end:
@@ -150,7 +160,7 @@ int consumer_metadata_cache_write(struct lttng_consumer_channel *channel,
 
        cache = channel->metadata_cache;
 
-       ret = metadata_cache_check_version(cache, channel, version);
+       ret = metadata_cache_check_version(cache, version);
        if (ret < 0) {
                goto end;
        }
@@ -263,9 +273,9 @@ int consumer_metadata_cache_flushed(struct lttng_consumer_channel *channel,
                pthread_mutex_lock(&channel->lock);
        }
        pthread_mutex_lock(&channel->timer_lock);
-       pthread_mutex_lock(&channel->metadata_cache->lock);
-
        metadata_stream = channel->metadata_stream;
+       pthread_mutex_lock(&metadata_stream->lock);
+       pthread_mutex_lock(&channel->metadata_cache->lock);
 
        if (!metadata_stream) {
                /*
@@ -285,6 +295,7 @@ int consumer_metadata_cache_flushed(struct lttng_consumer_channel *channel,
        }
 
        pthread_mutex_unlock(&channel->metadata_cache->lock);
+       pthread_mutex_unlock(&metadata_stream->lock);
        pthread_mutex_unlock(&channel->timer_lock);
        if (!timer) {
                pthread_mutex_unlock(&channel->lock);
This page took 0.033334 seconds and 4 git commands to generate.