Add a consumer daemon INIT command
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 12 Dec 2018 21:16:26 +0000 (16:16 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 18 Jul 2019 19:58:24 +0000 (15:58 -0400)
This commit adds an INIT commands which allows the session daemon
to provide its UUID as soon as the consumer daemon is started.

The name of this command is generic since other attributes may
need to be passed at the initialization of a consumer daemon.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-sessiond/consumer.c
src/common/consumer/consumer.c
src/common/consumer/consumer.h
src/common/kernel-consumer/kernel-consumer.c
src/common/ust-consumer/ust-consumer.c

index 12db236d08335c34221c7305527be81c049f97d1..336c7607104e1a982cb0f62b0622e9e65eb81bf9 100644 (file)
@@ -1894,3 +1894,27 @@ error:
        health_code_update();
        return ret;
 }
+
+int consumer_init(struct consumer_socket *socket,
+               const lttng_uuid sessiond_uuid)
+{
+       int ret;
+       struct lttcomm_consumer_msg msg = {
+               .cmd_type = LTTNG_CONSUMER_INIT,
+       };
+
+       assert(socket);
+
+       DBG("Sending consumer initialization command");
+       lttng_uuid_copy(msg.u.init.sessiond_uuid, sessiond_uuid);
+
+       health_code_update();
+       ret = consumer_send_msg(socket, &msg);
+       if (ret < 0) {
+               goto error;
+       }
+
+error:
+       health_code_update();
+       return ret;
+}
index e49ed94d12ca4d37d21294e94ae4f17db25f8d80..32a2d7a4a08c36f1aad2665172a8014b2c4122b0 100644 (file)
@@ -4485,3 +4485,21 @@ int lttng_consumer_mkdir(const char *path, uid_t uid, gid_t gid,
                return mkdir_local(path, uid, gid);
        }
 }
+
+enum lttcomm_return_code lttng_consumer_init_command(
+               struct lttng_consumer_local_data *ctx,
+               const lttng_uuid sessiond_uuid)
+{
+       enum lttcomm_return_code ret;
+
+       if (ctx->sessiond_uuid.is_set) {
+               ret = LTTCOMM_CONSUMERD_ALREADY_SET;
+               goto end;
+       }
+
+       ctx->sessiond_uuid.is_set = true;
+       memcpy(ctx->sessiond_uuid.value, sessiond_uuid, sizeof(lttng_uuid));
+       ret = LTTCOMM_CONSUMERD_SUCCESS;
+end:
+       return ret;
+}
index 0c757b84fb3c56b4399afee157d47fe0808b398a..83196444b9519ab2ad3d699a6e0edf64898781c5 100644 (file)
@@ -69,6 +69,7 @@ enum lttng_consumer_command {
        LTTNG_CONSUMER_CHECK_ROTATION_PENDING_LOCAL,
        LTTNG_CONSUMER_CHECK_ROTATION_PENDING_RELAY,
        LTTNG_CONSUMER_MKDIR,
+       LTTNG_CONSUMER_INIT,
 };
 
 /* State of each fd in consumer */
@@ -600,6 +601,7 @@ struct lttng_consumer_local_data {
         * to the session daemon (write-only).
         */
        int channel_monitor_pipe;
+       LTTNG_OPTIONAL(lttng_uuid) sessiond_uuid;
 };
 
 /*
@@ -863,5 +865,8 @@ void lttng_consumer_reset_stream_rotate_state(struct lttng_consumer_stream *stre
 int lttng_consumer_mkdir(const char *path, uid_t uid, gid_t gid,
                uint64_t relayd_id);
 void lttng_consumer_cleanup_relayd(struct consumer_relayd_sock_pair *relayd);
+enum lttcomm_return_code lttng_consumer_init_command(
+               struct lttng_consumer_local_data *ctx,
+               const lttng_uuid sessiond_uuid);
 
 #endif /* LIB_CONSUMER_H */
index 627cd2a8b5d7aad61ffc1d97794a0c2bbf756267..74c6de399af9f260264eac8a01894f4a1487c599 100644 (file)
@@ -1260,6 +1260,19 @@ int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx,
                }
                break;
        }
+       case LTTNG_CONSUMER_INIT:
+       {
+               ret_code = lttng_consumer_init_command(ctx,
+                               msg.u.init.sessiond_uuid);
+
+               health_code_update();
+               ret = consumer_send_status_msg(sock, ret_code);
+               if (ret < 0) {
+                       /* Somehow, the session daemon is not responding anymore. */
+                       goto end_nosignal;
+               }
+               break;
+       }
        default:
                goto end_nosignal;
        }
index 94b761cb8fc19fa532b4a485c178b4ac93aaee54..4d1737726c3b00a8a02cf068cc10dada125b9289 100644 (file)
@@ -2109,6 +2109,19 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx,
                }
                break;
        }
+       case LTTNG_CONSUMER_INIT:
+       {
+               ret_code = lttng_consumer_init_command(ctx,
+                               msg.u.init.sessiond_uuid);
+
+               health_code_update();
+               ret = consumer_send_status_msg(sock, ret_code);
+               if (ret < 0) {
+                       /* Somehow, the session daemon is not responding anymore. */
+                       goto end_nosignal;
+               }
+               break;
+       }
        default:
                break;
        }
This page took 0.031003 seconds and 4 git commands to generate.