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 23:07:07 +0000 (18:07 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 7 Nov 2014 23:07:37 +0000 (18:07 -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>
Conflicts:
src/bin/lttng/commands/list.c

src/bin/lttng-sessiond/cmd.c
src/bin/lttng-sessiond/main.c
src/bin/lttng/commands/list.c

index 8f8278eecd0d4515eda282495918c0c279e813f2..022d5cee14aef361780e400c37ef31877728550e 100644 (file)
@@ -2388,12 +2388,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;
        }
@@ -2406,10 +2406,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 a95f269d0a93d59220c45075f140b211359b34d0..e8e45115205256fed9cfdface11ae0aaea692268 100644 (file)
@@ -3315,7 +3315,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 0b1eff265b4635f4d1ffb0a568e5314d856256f8..dd39c4fc595cbc14ddfdab3eb450e338e10c7605 100644 (file)
@@ -688,7 +688,7 @@ static int list_channels(const char *channel_name)
                goto error_channels;
        }
 
-       if (channel_name == NULL) {
+       if (count) {
                MSG("Channels:\n-------------");
        }
 
This page took 0.03241 seconds and 4 git commands to generate.