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:07 +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 044e9eefec7e14eab9eb1046411395d1ccdebdff..79b1040121c6c3c3bd451fbab6ba5ad2cd4584dd 100644 (file)
@@ -2404,12 +2404,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;
        }
@@ -2422,10 +2422,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 ad136a3a2ef270e2b6aaa598fcd0e993b5d19966..36c99cda17fab631e89aee0fcde9ffdbf9e64518 100644 (file)
@@ -3472,7 +3472,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 f56adf4821db71ca4d8d4f77bc7adabd36444302..a91d30757e1b9bdbd698a317aa93d286c778a038 100644 (file)
@@ -720,7 +720,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.031618 seconds and 4 git commands to generate.