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 23:02:53 +0000 (18:02 -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 2a1bfb5f4670110e24ffab931f085dac4ed57f0c..62324455fe68aeee93fca8a4ebd8c00f8c19b6a3 100644 (file)
@@ -2435,12 +2435,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;
        }
@@ -2453,10 +2453,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 fa09758baa7083ed1a0b5c660fdf9f2e2b9ef03c..977f131c0c0db6a094b85620b826fe15e4114bb1 100644 (file)
@@ -3496,7 +3496,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 ea9427f4770f158458f6e8e79456f2f7d7b6c91b..5e9b28cff5bd295e557d17a2b561ad7d2d2fee02 100644 (file)
@@ -1202,7 +1202,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.033302 seconds and 4 git commands to generate.