Implement the relayd live features
[lttng-tools.git] / src / common / kernel-consumer / kernel-consumer.c
index 09ccda329526b69cf1e5aa147ed32f4dc8a67e81..4618ccedcd750d18d651c4ace97477dd620f9843 100644 (file)
@@ -39,6 +39,7 @@
 #include <common/utils.h>
 #include <common/consumer-stream.h>
 #include <common/index/index.h>
+#include <common/consumer-timer.h>
 
 #include "kernel-consumer.h"
 
@@ -441,7 +442,8 @@ int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx,
                /* Session daemon status message are handled in the following call. */
                ret = consumer_add_relayd_socket(msg.u.relayd_sock.net_index,
                                msg.u.relayd_sock.type, ctx, sock, consumer_sockpoll,
-                               &msg.u.relayd_sock.sock, msg.u.relayd_sock.session_id);
+                               &msg.u.relayd_sock.sock, msg.u.relayd_sock.session_id,
+                                msg.u.relayd_sock.relayd_session_id);
                goto end_nosignal;
        }
        case LTTNG_CONSUMER_ADD_CHANNEL:
@@ -462,7 +464,8 @@ int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx,
                                msg.u.channel.relayd_id, msg.u.channel.output,
                                msg.u.channel.tracefile_size,
                                msg.u.channel.tracefile_count, 0,
-                               msg.u.channel.monitor);
+                               msg.u.channel.monitor,
+                               msg.u.channel.live_timer_interval);
                if (new_channel == NULL) {
                        lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_OUTFD_ERROR);
                        goto end_nosignal;
@@ -501,6 +504,7 @@ int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx,
                } else {
                        ret = consumer_add_channel(new_channel, ctx);
                }
+               consumer_timer_live_start(new_channel, msg.u.channel.live_timer_interval);
 
                /* If we received an error in add_channel, we need to report it. */
                if (ret < 0) {
@@ -906,18 +910,13 @@ ssize_t lttng_kconsumer_read_subbuffer(struct lttng_consumer_stream *stream,
                struct lttng_consumer_local_data *ctx)
 {
        unsigned long len, subbuf_size, padding;
-       int err, write_index = 0;
+       int err, write_index = 1;
        ssize_t ret = 0;
        int infd = stream->wait_fd;
        struct lttng_packet_index index;
 
        DBG("In read_subbuffer (infd : %d)", infd);
 
-       /* Indicate that for this stream we have to write the index. */
-       if (stream->index_fd >= 0) {
-               write_index = 1;
-       }
-
        /* Get the next subbuffer */
        err = kernctl_get_next_subbuf(infd);
        if (err != 0) {
@@ -941,11 +940,13 @@ ssize_t lttng_kconsumer_read_subbuffer(struct lttng_consumer_stream *stream,
                goto end;
        }
 
-       if (!stream->metadata_flag && write_index) {
+       if (!stream->metadata_flag) {
                ret = get_index_values(&index, infd);
                if (ret < 0) {
                        goto end;
                }
+       } else {
+               write_index = 0;
        }
 
        switch (stream->chan->output) {
@@ -1027,12 +1028,13 @@ ssize_t lttng_kconsumer_read_subbuffer(struct lttng_consumer_stream *stream,
        }
 
        /* Write index if needed. */
-       if (write_index) {
-               err = index_write(stream->index_fd, &index, sizeof(index));
-               if (err < 0) {
-                       ret = -1;
-                       goto end;
-               }
+       if (!write_index) {
+               goto end;
+       }
+
+       err = consumer_stream_write_index(stream, &index);
+       if (err < 0) {
+               goto end;
        }
 
 end:
This page took 0.024214 seconds and 4 git commands to generate.