Fix: duplicated kernel consumer socket locking
[lttng-tools.git] / src / bin / lttng-sessiond / kernel-consumer.c
index a65e1493c384ea75401266b019b56ab605ce7e89..bc481e5c4cedbbfcac3818b85122a7aace36e8f7 100644 (file)
@@ -168,6 +168,9 @@ int kernel_consumer_add_channel(struct consumer_socket *sock,
                ret = -1;
                goto error;
        }
+
+       channel->published_to_notification_thread = true;
+
 error:
        free(pathname);
        return ret;
@@ -175,6 +178,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)
@@ -333,12 +338,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 */
@@ -356,9 +363,12 @@ 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 */
@@ -382,6 +392,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.024088 seconds and 4 git commands to generate.