[ LTTCOMM_ERR_INDEX(LTTCOMM_START_FAIL) ] = "Start trace failed",
[ LTTCOMM_ERR_INDEX(LTTCOMM_NO_TRACEABLE) ] = "App is not traceable",
[ LTTCOMM_ERR_INDEX(LTTCOMM_SELECT_SESS) ] = "A session MUST be selected",
+ [ LTTCOMM_ERR_INDEX(LTTCOMM_EXIST_SESS) ] = "Session name already exist",
};
/*
LTTCOMM_FATAL, /* Session daemon had a fatal error */
LTTCOMM_NO_TRACEABLE, /* Error for non traceable app */
LTTCOMM_SELECT_SESS, /* Must select a session */
+ LTTCOMM_EXIST_SESS, /* Session name already exist */
LTTCOMM_NR, /* Last element */
};
{
struct ltt_session *new_session;
+ new_session = find_session_by_name(name);
+ if (new_session != NULL) {
+ goto error;
+ }
+
/* Allocate session data structure */
new_session = malloc(sizeof(struct ltt_session));
if (new_session == NULL) {
perror("malloc");
- goto error;
+ goto error_mem;
}
if (name != NULL) {
if (asprintf(&new_session->name, "%s", name) < 0) {
- goto error;
+ goto error_mem;
}
} else {
/* Generate session name based on the session count */
if (asprintf(&new_session->name, "%s%d", "lttng-", session_count) < 0) {
- goto error;
+ goto error_mem;
}
}
error:
return -1;
+
+error_mem:
+ return -ENOMEM;
}
/*
{
ret = create_session(lsm->session_name, &llm.session_id);
if (ret < 0) {
+ if (ret == -1) {
+ ret = LTTCOMM_EXIST_SESS;
+ } else {
+ ret = LTTCOMM_FATAL;
+ }
goto end;
}
{
lttng_create_session "test-same"
lttng_create_session "test-same"
- if [ $LTTNG_RET_CODE -ne 1 ]; then
+ if [ $LTTNG_RET_CODE -ne 0 ]; then
echo "[-] Session with the same name: FAILED!"
printf "Two session having the same name NOT ALLOWED\n"
clean_exit 1