From: David Goulet Date: Thu, 16 Aug 2012 20:12:12 +0000 (-0400) Subject: Deny register consumer if one exists X-Git-Tag: v2.1.0-rc1~8 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=8d3113b21fe5ed84af58fbfdff9ad7742db507d5;p=lttng-tools.git 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 --- 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