From: David Goulet Date: Tue, 25 Feb 2014 19:22:19 +0000 (-0500) Subject: Fix: don't start session if no channel X-Git-Tag: v2.3.2~5 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=1148bd3a82f9819f3e59b9ce2b3adc139de9db45;p=lttng-tools.git Fix: don't start session if no channel This adds a new error code that indicates that the session contains NO channel. Fixes #715 Signed-off-by: David Goulet --- diff --git a/include/lttng/lttng-error.h b/include/lttng/lttng-error.h index 817cbe8f1..a94fcd697 100644 --- a/include/lttng/lttng-error.h +++ b/include/lttng/lttng-error.h @@ -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 */ diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index cca259923..2a61eee06 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -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 */ diff --git a/src/common/error.c b/src/common/error.c index 5020f316a..6c5aca65b 100644 --- a/src/common/error.c +++ b/src/common/error.c @@ -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"