Deny register consumer if one exists
authorDavid Goulet <dgoulet@efficios.com>
Thu, 16 Aug 2012 20:12:12 +0000 (16:12 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Thu, 16 Aug 2012 23:40:52 +0000 (19:40 -0400)
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 <julien.desfossez@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
src/bin/lttng-sessiond/main.c

index f24b317d02a89e5bedf8baee7d1a671076b95022..d0b1e17e544ef21b110381ea266f5037172e80f0 100644 (file)
@@ -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
This page took 0.033877 seconds and 4 git commands to generate.