From 8d3113b21fe5ed84af58fbfdff9ad7742db507d5 Mon Sep 17 00:00:00 2001 From: David Goulet Date: Thu, 16 Aug 2012 16:12:12 -0400 Subject: [PATCH] Deny register consumer if one exists Is a LTTNG_REGISTER_CONSUMER command is received and a consumer is already spawned, the command is denied returning a kernel consumer error. CC: Julien Desfossez Signed-off-by: David Goulet --- src/bin/lttng-sessiond/main.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index f24b317d0..d0b1e17e5 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -4328,6 +4328,16 @@ static int process_client_msg(struct command_ctx *cmd_ctx, int sock, goto error; } + /* Deny register consumer if we already have a spawned consumer. */ + if (cmd_ctx->lsm->cmd_type == LTTNG_REGISTER_CONSUMER) { + pthread_mutex_lock(&kconsumer_data.pid_mutex); + if (kconsumer_data.pid > 0) { + ret = LTTCOMM_KERN_CONSUMER_FAIL; + goto error; + } + pthread_mutex_unlock(&kconsumer_data.pid_mutex); + } + /* * Check for command that don't needs to allocate a returned payload. We do * this here so we don't have to make the call for no payload at each -- 2.34.1