Fix: Don't report an error when listing a session with no channels
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 7 Nov 2014 22:58:15 +0000 (17:58 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 7 Nov 2014 22:58:15 +0000 (17:58 -0500)
The LTTng sessiond daemon reports an error when the list_channel
command is invoked on a session which only has a metadata channel.

The error lies in assuming that a session which has an enabled
domains also has (user-visible) channels.

The metadata channel should be listed in a future fix.

Fixes #855

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-sessiond/cmd.c
src/bin/lttng-sessiond/main.c
src/bin/lttng/commands/list.c

index 98e090539af0ecf7755abc2dfe1332b2f116f3fa..17091de09ec66d9bd5b6028bbf04b90c7a99d5ff 100644 (file)
@@ -2451,12 +2451,12 @@ 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) {
+               if (nb_chan < 0) {
                        ret = LTTNG_ERR_UST_CHAN_NOT_FOUND;
+                       goto error;
                }
                break;
        default:
-               *channels = NULL;
                ret = LTTNG_ERR_UND;
                goto error;
        }
@@ -2469,10 +2469,6 @@ 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 c8484b93cb8a7006b708f562466cffc75aa4c767..9542e650dd6883b3351ae20ca249902259a3d94a 100644 (file)
@@ -3501,7 +3501,7 @@ skip_domain:
        case LTTNG_LIST_CHANNELS:
        {
                int nb_chan;
-               struct lttng_channel *channels;
+               struct lttng_channel *channels = NULL;
 
                nb_chan = cmd_list_channels(cmd_ctx->lsm->domain.type,
                                cmd_ctx->session, &channels);
index 7c3211a5927ffc2c34a0f3f5e72528be8c8c4575..12499ee408f1e545b3afbe727f2b0c3659a23082 100644 (file)
@@ -1207,7 +1207,7 @@ static int list_channels(const char *channel_name)
                }
        } else {
                /* Pretty print */
-               if (channel_name == NULL) {
+               if (count) {
                        MSG("Channels:\n-------------");
                }
 
This page took 0.032683 seconds and 4 git commands to generate.