{
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;
}
/*
{
int ret;
int buf_size;
+ size_t header_size;
char *send_buf = NULL;
struct lttcomm_lttng_msg llm;
}
}
-
/* Default return code.
* In our world, everything is OK... right? ;)
*/
llm.ret_code = LTTCOMM_OK;
+ header_size = sizeof(struct lttcomm_lttng_msg);
+
/* Process by command type */
switch (lsm->cmd_type) {
case LTTNG_CREATE_SESSION:
{
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;
}
goto end;
}
- get_list_apps((pid_t *)(send_buf + sizeof(struct lttcomm_lttng_msg)));
+ get_list_apps((pid_t *)(send_buf + header_size));
break;
}
goto end;
}
- get_list_sessions((struct lttng_session *)(send_buf + sizeof(struct lttcomm_lttng_msg)));
+ get_list_sessions((struct lttng_session *)(send_buf + header_size));
break;
}