From: David Goulet Date: Tue, 14 Feb 2012 22:31:57 +0000 (-0500) Subject: Small fix to lttng list session X-Git-Tag: v2.0-pre23~6 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=d32fb0935e594470f6a7e9ff0797ef101c500797;p=lttng-tools.git Small fix to lttng list session This patch makes lttng_list_sessions return 0 (not an error) when there is in fact zero registered sessions. Also adding a MSG() to the user to inform that no sessions exist and the error code is 0. Reported-by: Tan Dung Le Tran Acked-by: Mathieu Desnoyers Signed-off-by: David Goulet --- diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index 6c4b8ec5c..6ae374483 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -3477,11 +3477,7 @@ static int process_client_msg(struct command_ctx *cmd_ctx) session_lock_list(); nr_sessions = lttng_sessions_count(cmd_ctx->creds.uid, cmd_ctx->creds.gid); - if (nr_sessions == 0) { - ret = LTTCOMM_NO_SESSION; - session_unlock_list(); - goto error; - } + ret = setup_lttng_msg(cmd_ctx, sizeof(struct lttng_session) * nr_sessions); if (ret < 0) { session_unlock_list(); diff --git a/src/bin/lttng/commands/list.c b/src/bin/lttng/commands/list.c index 93758381c..f1707fc76 100644 --- a/src/bin/lttng/commands/list.c +++ b/src/bin/lttng/commands/list.c @@ -475,6 +475,9 @@ static int list_sessions(const char *session_name) if (count < 0) { ret = count; goto error; + } else if (count == 0) { + MSG("Currently no available tracing session"); + goto end; } if (session_name == NULL) { @@ -512,6 +515,7 @@ static int list_sessions(const char *session_name) MSG("\nUse lttng list for more details"); } +end: return CMD_SUCCESS; error: