Fix: sessiond: leak of trigger on registration error
[lttng-tools.git] / src / bin / lttng-sessiond / client.c
index e1552c345659184d7c3973393a656c520a7f85e5..c0086953a8e06bb1bb4405e3f0b3ba0954a407b4 100644 (file)
@@ -43,6 +43,7 @@
 #include "utils.h"
 #include "manage-consumer.h"
 #include "clear.h"
+#include "agent-thread.h"
 
 static bool is_root;
 
@@ -844,7 +845,9 @@ static int process_client_msg(struct command_ctx *cmd_ctx, int *sock,
        bool need_domain;
        bool need_consumerd;
 
-       DBG("Processing client command %d", cmd_ctx->lsm.cmd_type);
+       DBG("Processing client command '%s\' (%d)",
+               lttcomm_sessiond_command_str(cmd_ctx->lsm.cmd_type),
+               cmd_ctx->lsm.cmd_type);
 
        assert(!rcu_read_ongoing());
 
@@ -1076,6 +1079,11 @@ static int process_client_msg(struct command_ctx *cmd_ctx, int *sock,
        case LTTNG_DOMAIN_JUL:
        case LTTNG_DOMAIN_LOG4J:
        case LTTNG_DOMAIN_PYTHON:
+               if (!agent_tracing_is_enabled()) {
+                       ret = LTTNG_ERR_AGENT_TRACING_DISABLED;
+                       goto error;
+               }
+               /* Fallthrough */
        case LTTNG_DOMAIN_UST:
        {
                if (!ust_app_supported()) {
@@ -2608,6 +2616,11 @@ static void *thread_manage_clients(void *data)
                        continue;
                }
 
+               if (ret < LTTNG_OK || ret >= LTTNG_ERR_NR) {
+                       WARN("Command returned an invalid status code, returning unknown error: command type = %d, ret = %d", cmd_ctx.lsm.cmd_type, ret);
+                       ret = LTTNG_ERR_UNK;
+               }
+
                cmd_completion_handler = cmd_pop_completion_handler();
                if (cmd_completion_handler) {
                        enum lttng_error_code completion_code;
This page took 0.02397 seconds and 4 git commands to generate.