X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=lttng-sessiond%2Fsession.c;h=30ae681b353b7d4929f9921951f8cd70364b0736;hp=c7ce843d71669f3b40609293341dbf8f665a73a1;hb=a991f516ac2783c833ebbc6ac0ac3c0e4ca71371;hpb=322585731ced1adba36cddcb8bdd5d997d1b2e3e diff --git a/lttng-sessiond/session.c b/lttng-sessiond/session.c index c7ce843d7..30ae681b3 100644 --- a/lttng-sessiond/session.c +++ b/lttng-sessiond/session.c @@ -55,11 +55,12 @@ static struct ltt_session_list ltt_session_list = { * Add a ltt_session structure to the global list. * * The caller MUST acquire the session list lock before. + * Returns the unique identifier for the session. */ -static void add_session_list(struct ltt_session *ls) +static int add_session_list(struct ltt_session *ls) { cds_list_add(&ls->list, <t_session_list.head); - ltt_session_list.count++; + return ++ltt_session_list.count; } /* @@ -175,9 +176,9 @@ int session_create(char *name, char *path) } /* Allocate session data structure */ - new_session = malloc(sizeof(struct ltt_session)); + new_session = zmalloc(sizeof(struct ltt_session)); if (new_session == NULL) { - perror("malloc"); + perror("zmalloc"); ret = LTTCOMM_FATAL; goto error_malloc; } @@ -215,10 +216,10 @@ int session_create(char *name, char *path) /* Add new session to the session list */ session_lock_list(); - add_session_list(new_session); + new_session->id = add_session_list(new_session); session_unlock_list(); - DBG("Tracing session %s created in %s", name, path); + DBG("Tracing session %s created in %s with ID %d", name, path, new_session->id); return LTTCOMM_OK;