{
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;
}
*/
if ((ret = check_existing_daemon()) == 0) {
ERR("Already running daemon.\n");
- goto error;
+ /* We do not goto error because we must not
+ * cleanup() because a daemon is already working.
+ */
+ return EXIT_FAILURE;
}
if (set_signal_handler() < 0) {