[lttng-dev] [lttng-tools PATCH] Small fix to lttng list session

David Goulet dgoulet at efficios.com
Tue Feb 14 17:35:13 EST 2012


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 <tan.dung.le.tran at ericsson.com>
Signed-off-by: David Goulet <dgoulet at efficios.com>
---
 src/bin/lttng-sessiond/main.c |    2 +-
 src/bin/lttng/commands/list.c |    4 ++++
 2 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c
index 6c4b8ec..e44209a 100644
--- a/src/bin/lttng-sessiond/main.c
+++ b/src/bin/lttng-sessiond/main.c
@@ -3478,7 +3478,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;
+			ret = LTTCOMM_OK;
 			session_unlock_list();
 			goto error;
 		}
diff --git a/src/bin/lttng/commands/list.c b/src/bin/lttng/commands/list.c
index 9375838..f1707fc 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 <session_name> for more details");
 	}
 
+end:
 	return CMD_SUCCESS;
 
 error:
-- 
1.7.9




More information about the lttng-dev mailing list