Fix: disable-event/channel return error if no domain
authorDavid Goulet <dgoulet@efficios.com>
Wed, 21 May 2014 16:09:15 +0000 (12:09 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Wed, 21 May 2014 17:37:36 +0000 (13:37 -0400)
The disable-event/channel command now check for a UST/kernel session
before trying to disable the object. If none exists, it returns an error
without creating a domain.

Fixes #638

Signed-off-by: David Goulet <dgoulet@efficios.com>
src/bin/lttng-sessiond/main.c

index 5448259e5f58e47b6abf05e02a253a5399a00d8e..1d218b170ec31112f750d5ffae02ff3d41080870 100644 (file)
@@ -2822,6 +2822,38 @@ static int process_client_msg(struct command_ctx *cmd_ctx, int sock,
                break;
        }
 
+       /*
+        * Commands that need a valid session but should NOT create one if none
+        * exists. Instead of creating one and destroying it when the command is
+        * handled, process that right before so we save some round trip in useless
+        * code path.
+        */
+       switch (cmd_ctx->lsm->cmd_type) {
+       case LTTNG_DISABLE_CHANNEL:
+       case LTTNG_DISABLE_EVENT:
+       case LTTNG_DISABLE_ALL_EVENT:
+               switch (cmd_ctx->lsm->domain.type) {
+               case LTTNG_DOMAIN_KERNEL:
+                       if (!cmd_ctx->session->kernel_session) {
+                               ret = LTTNG_ERR_NO_CHANNEL;
+                               goto error;
+                       }
+                       break;
+               case LTTNG_DOMAIN_JUL:
+               case LTTNG_DOMAIN_UST:
+                       if (!cmd_ctx->session->ust_session) {
+                               ret = LTTNG_ERR_NO_CHANNEL;
+                               goto error;
+                       }
+                       break;
+               default:
+                       ret = LTTNG_ERR_UNKNOWN_DOMAIN;
+                       goto error;
+               }
+       default:
+               break;
+       }
+
        if (!need_domain) {
                goto skip_domain;
        }
This page took 0.029303 seconds and 5 git commands to generate.