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:22:19 +0000 (14:22 -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 93a8c2187ee28d825822f3db803583e9dd75f423..93196fe2be705b5eb6ec37ad8939ba01bfb76c09 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 dc465173e3521984f48b91f23e1782b83ba22b09..5bf00be8536f12cb124fd0d828486344b75734b7 100644 (file)
@@ -1779,6 +1779,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;
 
@@ -1794,6 +1795,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 b5e3fcea1c83f89329b72c780125a0d9473e891c..bff21ae7139782bf0b5ca49e06418731759abfd0 100644 (file)
@@ -115,6 +115,7 @@ static const char *error_string_array[] = {
        [ ERROR_INDEX(LTTNG_ERR_SNAPSHOT_FAIL) ] = "Snapshot record failed",
        [ ERROR_INDEX(LTTNG_ERR_CHAN_EXIST) ] = "Channel already exists",
        [ 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.029282 seconds and 5 git commands to generate.