X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=ltt-sessiond%2Fltt-sessiond.c;h=275088f075e959fcfe07ddbd966c73c060646fdd;hp=839c5204d08db774653090516a1cf803d968c854;hb=27673bb674a1b11ad5f11f585360e031b5baccb1;hpb=6e0ca3c2c2afedf4a944cec63a6a566f7014c93f diff --git a/ltt-sessiond/ltt-sessiond.c b/ltt-sessiond/ltt-sessiond.c index 839c5204d..275088f07 100644 --- a/ltt-sessiond/ltt-sessiond.c +++ b/ltt-sessiond/ltt-sessiond.c @@ -477,21 +477,26 @@ static int create_session(char *name, uuid_t *session_id) { 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; } } @@ -516,6 +521,9 @@ static int create_session(char *name, uuid_t *session_id) error: return -1; + +error_mem: + return -ENOMEM; } /* @@ -708,6 +716,11 @@ static int process_client_msg(int sock, struct lttcomm_session_msg *lsm) { 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; }