Fix: Returned code when listing kernel channel
authorDavid Goulet <dgoulet@efficios.com>
Mon, 24 Sep 2012 20:55:08 +0000 (16:55 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Mon, 24 Sep 2012 21:24:58 +0000 (17:24 -0400)
The lttng_list_channels() API call now returns a
LTTNG_ERR_KERN_CHAN_NOT_FOUND or LTTNG_ERR_UST_CHAN_NOT_FOUND when there
is no channel enabled for the session and domain.

Changes had to be made to the list command in order to correctly manage
the returned code.

The bug260 mentionned that the session(s) were destroyed but this could
not be reproduce. However, the rest of the bug description is valid.

Fixes #260

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

index 460f1d69fda2672cadbcb35a2992d4ba2a208a1c..06bf0f4f386832a199a199862e2416301d42e521 100644 (file)
@@ -1928,6 +1928,9 @@ ssize_t cmd_list_channels(int domain, struct ltt_session *session,
                        nb_chan = session->kernel_session->channel_count;
                }
                DBG3("Number of kernel channels %zd", nb_chan);
+               if (nb_chan <= 0) {
+                       ret = LTTNG_ERR_KERN_CHAN_NOT_FOUND;
+               }
                break;
        case LTTNG_DOMAIN_UST:
                if (session->ust_session != NULL) {
@@ -1935,6 +1938,9 @@ ssize_t cmd_list_channels(int domain, struct ltt_session *session,
                                        session->ust_session->domain_global.channels);
                }
                DBG3("Number of UST global channels %zd", nb_chan);
+               if (nb_chan <= 0) {
+                       ret = LTTNG_ERR_UST_CHAN_NOT_FOUND;
+               }
                break;
        default:
                *channels = NULL;
@@ -1952,6 +1958,8 @@ ssize_t cmd_list_channels(int domain, struct ltt_session *session,
                list_lttng_channels(domain, session, *channels);
        } else {
                *channels = NULL;
+               /* Ret value was set in the domain switch case */
+               goto error;
        }
 
        return nb_chan;
index 696e80e7f2c9a8bfd3e54de5c4caba0024e68b84..28e18644403142592ad2547476d8c41384d2163c 100644 (file)
@@ -521,11 +521,17 @@ static int list_channels(const char *channel_name)
 
        count = lttng_list_channels(handle, &channels);
        if (count < 0) {
-               ret = count;
+               switch (-count) {
+               case LTTNG_ERR_KERN_CHAN_NOT_FOUND:
+                       ret = CMD_SUCCESS;
+                       WARN("No kernel channel");
+                       break;
+               default:
+                       /* We had a real error */
+                       ret = count;
+                       ERR("%s", lttng_strerror(ret));
+               }
                goto error_channels;
-       } else if (count == 0) {
-               ERR("Channel %s not found", channel_name);
-               goto error;
        }
 
        if (channel_name == NULL) {
This page took 0.032428 seconds and 4 git commands to generate.