Clean-up: consumer: fix -Wshadow error in lttng_consumer_trace_chunk_exists
[lttng-tools.git] / src / common / consumer / consumer.c
index 2cd385545ab357faa7faeead6c770db877dc8e97..27a01bd7a4c162c83b92f8c5ff10386771f9dab9 100644 (file)
@@ -877,6 +877,43 @@ error:
        return outfd;
 }
 
+/*
+ * Write a character on the metadata poll pipe to wake the metadata thread.
+ * Returns 0 on success, -1 on error.
+ */
+int consumer_metadata_wakeup_pipe(const struct lttng_consumer_channel *channel)
+{
+       int ret = 0;
+
+       DBG("Waking up metadata poll thread (writing to pipe): channel name = '%s'",
+                       channel->name);
+       if (channel->monitor && channel->metadata_stream) {
+               const char dummy = 'c';
+               const ssize_t write_ret = lttng_write(
+                               channel->metadata_stream->ust_metadata_poll_pipe[1],
+                               &dummy, 1);
+
+               if (write_ret < 1) {
+                       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("Failed to write to UST metadata pipe while attempting to wake-up the metadata poll thread");
+                               ret = -1;
+                               goto end;
+                       }
+               }
+       }
+
+end:
+       return ret;
+}
+
 /*
  * Trigger a dump of the metadata content. Following/during the succesful
  * completion of this call, the metadata poll thread will start receiving
@@ -4057,7 +4094,6 @@ int lttng_consumer_rotate_channel(struct lttng_consumer_channel *channel,
                                         */
                                        flush_active = produced_pos != consumed_pos;
                                        if (!flush_active) {
-                                               enum lttng_trace_chunk_status chunk_status;
                                                const char *trace_chunk_name;
                                                uint64_t trace_chunk_id;
 
@@ -4706,9 +4742,9 @@ enum lttcomm_return_code lttng_consumer_create_trace_chunk(
                } else {
                        relayd_id_str = "(formatting error)";
                }
-        }
+       }
 
-        /* Local protocol error. */
+       /* Local protocol error. */
        assert(chunk_creation_timestamp);
        ret = time_to_iso8601_str(chunk_creation_timestamp,
                        creation_timestamp_buffer,
@@ -5007,8 +5043,6 @@ enum lttcomm_return_code lttng_consumer_trace_chunk_exists(
        bool chunk_exists_local, chunk_exists_remote;
 
        if (relayd_id) {
-               int ret;
-
                /* Only used for logging purposes. */
                ret = snprintf(relayd_id_buffer, sizeof(relayd_id_buffer),
                                "%" PRIu64, *relayd_id);
@@ -5017,7 +5051,7 @@ enum lttcomm_return_code lttng_consumer_trace_chunk_exists(
                } else {
                        relayd_id_str = "(formatting error)";
                }
-        }
+       }
 
        DBG("Consumer trace chunk exists command: relayd_id = %s"
                        ", chunk_id = %" PRIu64, relayd_id_str,
This page took 0.02418 seconds and 4 git commands to generate.