Fix: send the streams sent message after metadata
authorJulien Desfossez <jdesfossez@efficios.com>
Wed, 15 Jan 2014 16:29:36 +0000 (11:29 -0500)
committerDavid Goulet <dgoulet@efficios.com>
Fri, 7 Feb 2014 20:27:33 +0000 (15:27 -0500)
We now make sure that we only sent the streams_sent message to the relay
when all the streams (including the metadata) are sent.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
src/bin/lttng-relayd/main.c
src/bin/lttng-sessiond/kernel-consumer.c
src/common/kernel-consumer/kernel-consumer.c
src/common/ust-consumer/ust-consumer.c

index fe4a898bc6d349dfd866218e597d77ef12a746aa..d8105e4058128bdc9a902bb8051fc991971f2b90 100644 (file)
@@ -1350,11 +1350,7 @@ int relay_add_stream(struct lttcomm_relayd_hdr *recv_hdr,
         * stream message is received, this list is emptied and streams are set
         * with the viewer ready flag.
         */
-       if (stream->metadata_flag) {
-               stream->viewer_ready = 1;
-       } else {
-               queue_stream_handle(stream->stream_handle, cmd);
-       }
+       queue_stream_handle(stream->stream_handle, cmd);
 
        lttng_ht_node_init_ulong(&stream->stream_n,
                        (unsigned long) stream->stream_handle);
index 4c069588a36cf36ce8755433f2f03c480df06ba4..4153612746f90c84780b208b94ce2ce731126217 100644 (file)
@@ -305,7 +305,6 @@ int kernel_consumer_send_channel_stream(struct consumer_socket *sock,
 {
        int ret;
        struct ltt_kernel_stream *stream;
-       uint64_t channel_key = -1ULL;
 
        /* Safety net */
        assert(channel);
@@ -339,22 +338,8 @@ int kernel_consumer_send_channel_stream(struct consumer_socket *sock,
                if (ret < 0) {
                        goto error;
                }
-               if (channel_key == -1ULL) {
-                       channel_key = channel->fd;
-               }
-       }
-
-       if (!monitor || channel_key == -1ULL) {
-               goto end;
-       }
-
-       /* Add stream on the kernel consumer side. */
-       ret = kernel_consumer_streams_sent(sock, session, channel_key);
-       if (ret < 0) {
-               goto error;
        }
 
-end:
 error:
        return ret;
 }
@@ -403,6 +388,16 @@ int kernel_consumer_send_session(struct consumer_socket *sock,
                if (ret < 0) {
                        goto error;
                }
+               if (monitor) {
+                       /*
+                        * Inform the relay that all the streams for the
+                        * channel were sent.
+                        */
+                       ret = kernel_consumer_streams_sent(sock, session, chan->fd);
+                       if (ret < 0) {
+                               goto error;
+                       }
+               }
        }
 
        DBG("Kernel consumer FDs of metadata and channel streams sent");
index c95355e9a472e35970ab7b734b18611d14bc356c..0b793c9032e484cc55ae3c3f4b9372c07ffdc35c 100644 (file)
@@ -176,10 +176,12 @@ int lttng_kconsumer_snapshot_channel(uint64_t key, char *path,
                        DBG("Kernel consumer snapshot stream %s/%s (%" PRIu64 ")",
                                        path, stream->name, stream->key);
                }
-               ret = consumer_send_relayd_streams_sent(relayd_id);
-               if (ret < 0) {
-                       ERR("sending streams sent to relayd");
-                       goto end_unlock;
+               if (relayd_id != -1ULL) {
+                       ret = consumer_send_relayd_streams_sent(relayd_id);
+                       if (ret < 0) {
+                               ERR("sending streams sent to relayd");
+                               goto end_unlock;
+                       }
                }
 
                ret = kernctl_buffer_flush(stream->wait_fd);
index af3aca0a5dfad074ba163a875770244af13e475b..bdabb5e49fcda0e44d6c65018efc0b4f296c6730 100644 (file)
@@ -438,17 +438,6 @@ static int send_sessiond_channel(int sock,
                                net_seq_idx = stream->net_seq_idx;
                        }
                }
-               ret = consumer_send_relayd_streams_sent(net_seq_idx);
-               if (ret < 0) {
-                       /*
-                        * Flag that the relayd was the problem here probably due to a
-                        * communicaton error on the socket.
-                        */
-                       if (relayd_error) {
-                               *relayd_error = 1;
-                       }
-                       ret_code = LTTNG_ERR_RELAYD_CONNECT_FAIL;
-               }
        }
 
        /* Inform sessiond that we are about to send channel and streams. */
@@ -769,6 +758,12 @@ static int setup_metadata(struct lttng_consumer_local_data *ctx, uint64_t key)
                        ret = LTTCOMM_CONSUMERD_ERROR_METADATA;
                        goto error;
                }
+               ret = consumer_send_relayd_streams_sent(
+                               metadata->metadata_stream->net_seq_idx);
+               if (ret < 0) {
+                       ret = LTTCOMM_CONSUMERD_RELAYD_FAIL;
+                       goto error;
+               }
        }
 
        ret = send_streams_to_thread(metadata, ctx);
This page took 0.030573 seconds and 5 git commands to generate.