Fix: don't start session if no channel
authorDavid Goulet <dgoulet@efficios.com>
Tue, 25 Feb 2014 19:22:19 +0000 (14:22 -0500)
committerDavid Goulet <dgoulet@efficios.com>
Tue, 25 Feb 2014 19:23:21 +0000 (14:23 -0500)
This adds a new error code that indicates that the session contains NO
channel.

Fixes #715

Signed-off-by: David Goulet <dgoulet@efficios.com>
include/lttng/lttng-error.h
src/bin/lttng-sessiond/cmd.c
src/common/error.c

index 817cbe8f1bab8b30e2717e327d843ce45a2616b3..a94fcd69747775d0faded80ec0d4b23e1392c9ed 100644 (file)
@@ -102,7 +102,7 @@ enum lttng_error_code {
        LTTNG_ERR_UST_CONSUMER32_FAIL    = 69,  /* 32-bit UST consumer start failed */
        LTTNG_ERR_UST_STREAM_FAIL        = 70,  /* UST create stream failed */
        LTTNG_ERR_SNAPSHOT_NODATA        = 71,  /* No data in snapshot. */
-       /* 72 */
+       LTTNG_ERR_NO_CHANNEL             = 72,  /* No channel found in the session. */
        /* 73 */
        LTTNG_ERR_UST_LIST_FAIL          = 74,  /* UST listing events failed */
        LTTNG_ERR_UST_EVENT_EXIST        = 75,  /* UST event exist */
index cca25992313cd8c48f5f049d717cff73e6a41045..2a61eee064f5af2fa558e73db87f2057fd8eb120 100644 (file)
@@ -1583,6 +1583,7 @@ error:
 int cmd_start_trace(struct ltt_session *session)
 {
        int ret;
+       unsigned long nb_chan = 0;
        struct ltt_kernel_session *ksession;
        struct ltt_ust_session *usess;
 
@@ -1598,6 +1599,21 @@ int cmd_start_trace(struct ltt_session *session)
                goto error;
        }
 
+       /*
+        * Starting a session without channel is useless since after that it's not
+        * possible to enable channel thus inform the client.
+        */
+       if (usess && usess->domain_global.channels) {
+               nb_chan += lttng_ht_get_count(usess->domain_global.channels);
+       }
+       if (ksession) {
+               nb_chan += ksession->channel_count;
+       }
+       if (!nb_chan) {
+               ret = LTTNG_ERR_NO_CHANNEL;
+               goto error;
+       }
+
        session->enabled = 1;
 
        /* Kernel tracing */
index 5020f316af8a94e6345149d0d82d3f1f608687bc..6c5aca65b40888aaf18d17d3aa9cf70c49a41736 100644 (file)
@@ -114,6 +114,7 @@ static const char *error_string_array[] = {
        [ ERROR_INDEX(LTTNG_ERR_START_SESSION_ONCE) ] = "Session needs to be started once",
        [ ERROR_INDEX(LTTNG_ERR_SNAPSHOT_FAIL) ] = "Snapshot record failed",
        [ ERROR_INDEX(LTTNG_ERR_SNAPSHOT_NODATA) ] = "No data available in snapshot",
+       [ ERROR_INDEX(LTTNG_ERR_NO_CHANNEL) ] = "No channel found in the session",
 
        /* Last element */
        [ ERROR_INDEX(LTTNG_ERR_NR) ] = "Unknown error code"
This page took 0.02936 seconds and 4 git commands to generate.