Implement the relayd live features
[lttng-tools.git] / src / bin / lttng-sessiond / consumer.c
index d79dee3cafd99c1232f2458a985561fb0e7a1875..f0870e6b0c0abcf2ae50e83c32df5ef2b162a33e 100644 (file)
@@ -28,6 +28,7 @@
 #include <common/common.h>
 #include <common/defaults.h>
 #include <common/uri.h>
+#include <common/relayd/relayd.h>
 
 #include "consumer.h"
 #include "health.h"
@@ -62,8 +63,8 @@ int consumer_socket_send(struct consumer_socket *socket, void *msg, size_t len)
                /* The above call will print a PERROR on error. */
                DBG("Error when sending data to consumer on sock %d", fd);
                /*
-                * At this point, the socket is not usable anymore thus flagging it
-                * invalid and closing it.
+                * At this point, the socket is not usable anymore thus closing it and
+                * setting the file descriptor to -1 so it is not reused.
                 */
 
                /* This call will PERROR on error. */
@@ -106,8 +107,8 @@ int consumer_socket_recv(struct consumer_socket *socket, void *msg, size_t len)
                /* The above call will print a PERROR on error. */
                DBG("Error when receiving data from the consumer socket %d", fd);
                /*
-                * At this point, the socket is not usable anymore thus flagging it
-                * invalid and closing it.
+                * At this point, the socket is not usable anymore thus closing it and
+                * setting the file descriptor to -1 so it is not reused.
                 */
 
                /* This call will PERROR on error. */
@@ -781,6 +782,7 @@ void consumer_init_ask_channel_comm_msg(struct lttcomm_consumer_msg *msg,
                int overwrite,
                unsigned int switch_timer_interval,
                unsigned int read_timer_interval,
+               unsigned int live_timer_interval,
                int output,
                int type,
                uint64_t session_id,
@@ -809,6 +811,7 @@ void consumer_init_ask_channel_comm_msg(struct lttcomm_consumer_msg *msg,
        msg->u.ask_channel.overwrite = overwrite;
        msg->u.ask_channel.switch_timer_interval = switch_timer_interval;
        msg->u.ask_channel.read_timer_interval = read_timer_interval;
+       msg->u.ask_channel.live_timer_interval = live_timer_interval;
        msg->u.ask_channel.output = output;
        msg->u.ask_channel.type = type;
        msg->u.ask_channel.session_id = session_id;
@@ -852,7 +855,8 @@ void consumer_init_channel_comm_msg(struct lttcomm_consumer_msg *msg,
                int type,
                uint64_t tracefile_size,
                uint64_t tracefile_count,
-               unsigned int monitor)
+               unsigned int monitor,
+               unsigned int live_timer_interval)
 {
        assert(msg);
 
@@ -872,6 +876,7 @@ void consumer_init_channel_comm_msg(struct lttcomm_consumer_msg *msg,
        msg->u.channel.tracefile_size = tracefile_size;
        msg->u.channel.tracefile_count = tracefile_count;
        msg->u.channel.monitor = monitor;
+       msg->u.channel.live_timer_interval = live_timer_interval;
 
        strncpy(msg->u.channel.pathname, pathname,
                        sizeof(msg->u.channel.pathname));
@@ -935,7 +940,8 @@ error:
  */
 int consumer_send_relayd_socket(struct consumer_socket *consumer_sock,
                struct lttcomm_relayd_sock *rsock, struct consumer_output *consumer,
-               enum lttng_stream_type type, uint64_t session_id)
+               enum lttng_stream_type type, uint64_t session_id,
+               char *session_name, char *hostname, int session_live_timer)
 {
        int ret;
        struct lttcomm_consumer_msg msg;
@@ -951,6 +957,17 @@ int consumer_send_relayd_socket(struct consumer_socket *consumer_sock,
                goto error;
        }
 
+       if (type == LTTNG_STREAM_CONTROL) {
+               ret = relayd_create_session(rsock,
+                               &msg.u.relayd_sock.relayd_session_id,
+                               session_name, hostname, session_live_timer);
+               if (ret < 0) {
+                       /* Close the control socket. */
+                       (void) relayd_close(rsock);
+                       goto error;
+               }
+       }
+
        msg.cmd_type = LTTNG_CONSUMER_ADD_RELAYD_SOCKET;
        /*
         * Assign network consumer output index using the temporary consumer since
This page took 0.028498 seconds and 5 git commands to generate.