consumerd: tag metadata channel as being part of a live session
[lttng-tools.git] / src / bin / lttng-sessiond / kernel-consumer.c
index 7582d80f0dea7eaf17d6d805eb680a4dbb657f15..a086384aca782141b5ce8d162550880871b79547 100644 (file)
@@ -132,7 +132,8 @@ int kernel_consumer_add_channel(struct consumer_socket *sock,
                        channel->channel->attr.tracefile_size,
                        channel->channel->attr.tracefile_count,
                        monitor,
-                       channel->channel->attr.live_timer_interval);
+                       channel->channel->attr.live_timer_interval,
+                       session->is_live_session);
 
        health_code_update();
 
@@ -150,6 +151,8 @@ error:
 
 /*
  * Sending metadata to the consumer with command ADD_CHANNEL and ADD_STREAM.
+ *
+ * The consumer socket lock must be held by the caller.
  */
 int kernel_consumer_add_metadata(struct consumer_socket *sock,
                struct ltt_kernel_session *session, unsigned int monitor)
@@ -194,7 +197,7 @@ int kernel_consumer_add_metadata(struct consumer_socket *sock,
                        DEFAULT_KERNEL_CHANNEL_OUTPUT,
                        CONSUMER_CHANNEL_TYPE_METADATA,
                        0, 0,
-                       monitor, 0);
+                       monitor, 0, session->is_live_session);
 
        health_code_update();
 
@@ -308,12 +311,14 @@ error:
 
 /*
  * Send all stream fds of kernel channel to the consumer.
+ *
+ * The consumer socket lock must be held by the caller.
  */
 int kernel_consumer_send_channel_stream(struct consumer_socket *sock,
                struct ltt_kernel_channel *channel, struct ltt_kernel_session *session,
                unsigned int monitor)
 {
-       int ret;
+       int ret = LTTNG_OK;
        struct ltt_kernel_stream *stream;
 
        /* Safety net */
@@ -331,14 +336,17 @@ int kernel_consumer_send_channel_stream(struct consumer_socket *sock,
        DBG("Sending streams of channel %s to kernel consumer",
                        channel->channel->name);
 
-       ret = kernel_consumer_add_channel(sock, channel, session, monitor);
-       if (ret < 0) {
-               goto error;
+       if (!channel->sent_to_consumer) {
+               ret = kernel_consumer_add_channel(sock, channel, session, monitor);
+               if (ret < 0) {
+                       goto error;
+               }
+               channel->sent_to_consumer = true;
        }
 
        /* Send streams */
        cds_list_for_each_entry(stream, &channel->stream_list.head, list) {
-               if (!stream->fd) {
+               if (!stream->fd || stream->sent_to_consumer) {
                        continue;
                }
 
@@ -348,6 +356,7 @@ int kernel_consumer_send_channel_stream(struct consumer_socket *sock,
                if (ret < 0) {
                        goto error;
                }
+               stream->sent_to_consumer = true;
        }
 
 error:
@@ -356,6 +365,8 @@ error:
 
 /*
  * Send all stream fds of the kernel session to the consumer.
+ *
+ * The consumer socket lock must be held by the caller.
  */
 int kernel_consumer_send_session(struct consumer_socket *sock,
                struct ltt_kernel_session *session)
This page took 0.029252 seconds and 5 git commands to generate.