From: David Goulet Date: Mon, 5 Mar 2012 14:56:40 +0000 (-0500) Subject: Fix start/stop lttng message error X-Git-Tag: v2.0.0-rc3~15 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=80e327fa80045f6b470ac76963fc4b5d396a80a9;p=lttng-tools.git Fix start/stop lttng message error Add the already started/stopped error message and print a more meaningful error on the command line. (closes #47) Signed-off-by: David Goulet --- diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index 12322837e..b275874e7 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -2850,7 +2850,8 @@ static int cmd_start_trace(struct ltt_session *session) usess = session->ust_session; if (session->enabled) { - ret = LTTCOMM_UST_START_FAIL; + /* Already started. */ + ret = LTTCOMM_TRACE_ALREADY_STARTED; goto error; } @@ -2942,7 +2943,7 @@ static int cmd_stop_trace(struct ltt_session *session) usess = session->ust_session; if (!session->enabled) { - ret = LTTCOMM_UST_STOP_FAIL; + ret = LTTCOMM_TRACE_ALREADY_STOPPED; goto error; } diff --git a/src/common/sessiond-comm/sessiond-comm.c b/src/common/sessiond-comm/sessiond-comm.c index 96615f438..53d8d7ca5 100644 --- a/src/common/sessiond-comm/sessiond-comm.c +++ b/src/common/sessiond-comm/sessiond-comm.c @@ -101,6 +101,10 @@ static const char *lttcomm_readable_code[] = { [ LTTCOMM_ERR_INDEX(LTTCOMM_UST_EVENT_NOT_FOUND)] = "UST event not found", [ LTTCOMM_ERR_INDEX(LTTCOMM_UST_CONTEXT_EXIST)] = "UST context already exist", [ LTTCOMM_ERR_INDEX(LTTCOMM_UST_CONTEXT_INVAL)] = "UST invalid context", + [ LTTCOMM_ERR_INDEX(LTTCOMM_NEED_ROOT_SESSIOND) ] = "A root lttng-sessiond needs to be running, and client user part of the \"tracing\" group, to interact with kernel tracing", + [ LTTCOMM_ERR_INDEX(LTTCOMM_TRACE_ALREADY_STARTED) ] = "Tracing already started", + [ LTTCOMM_ERR_INDEX(LTTCOMM_TRACE_ALREADY_STOPPED) ] = "Tracing already stopped", + [ LTTCOMM_ERR_INDEX(CONSUMERD_COMMAND_SOCK_READY) ] = "consumerd command socket ready", [ LTTCOMM_ERR_INDEX(CONSUMERD_SUCCESS_RECV_FD) ] = "consumerd success on receiving fds", [ LTTCOMM_ERR_INDEX(CONSUMERD_ERROR_RECV_FD) ] = "consumerd error on receiving fds", @@ -116,7 +120,6 @@ static const char *lttcomm_readable_code[] = { [ LTTCOMM_ERR_INDEX(CONSUMERD_SPLICE_ENOMEM) ] = "consumerd splice ENOMEM", [ LTTCOMM_ERR_INDEX(CONSUMERD_SPLICE_ESPIPE) ] = "consumerd splice ESPIPE", [ LTTCOMM_ERR_INDEX(LTTCOMM_NO_EVENT) ] = "Event not found", - [ LTTCOMM_ERR_INDEX(LTTCOMM_NEED_ROOT_SESSIOND) ] = "A root lttng-sessiond needs to be running, and client user part of the \"tracing\" group, to interact with kernel tracing", }; /* diff --git a/src/common/sessiond-comm/sessiond-comm.h b/src/common/sessiond-comm/sessiond-comm.h index 17cb51915..73abfe84a 100644 --- a/src/common/sessiond-comm/sessiond-comm.h +++ b/src/common/sessiond-comm/sessiond-comm.h @@ -136,6 +136,9 @@ enum lttcomm_return_code { LTTCOMM_UST_EVENT_NOT_FOUND, /* UST event not found */ LTTCOMM_UST_CONTEXT_EXIST, /* UST context exist */ LTTCOMM_UST_CONTEXT_INVAL, /* UST context invalid */ + LTTCOMM_NEED_ROOT_SESSIOND, /* root sessiond is needed */ + LTTCOMM_TRACE_ALREADY_STARTED, /* Tracing already started */ + LTTCOMM_TRACE_ALREADY_STOPPED, /* Tracing already stopped */ CONSUMERD_COMMAND_SOCK_READY, /* when consumerd command socket ready */ CONSUMERD_SUCCESS_RECV_FD, /* success on receiving fds */ @@ -151,7 +154,7 @@ enum lttcomm_return_code { CONSUMERD_SPLICE_EINVAL, /* EINVAL from splice(2) */ CONSUMERD_SPLICE_ENOMEM, /* ENOMEM from splice(2) */ CONSUMERD_SPLICE_ESPIPE, /* ESPIPE from splice(2) */ - LTTCOMM_NEED_ROOT_SESSIOND, /* root sessiond is needed */ + /* MUST be last element */ LTTCOMM_NR, /* Last element */ };