Allocate session UID with count increment
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 21 Nov 2011 15:55:25 +0000 (16:55 +0100)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 21 Nov 2011 15:55:25 +0000 (16:55 +0100)
Otherwise, the UST session UID gets assigned only when the first UST
channel is created for a session, causing IDs to be used for many
sessions (the count of the number of sessions allocated so far) if the
session creation / channel creation is not performed in a usual
sequence.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
lttng-sessiond/main.c
lttng-sessiond/session.c
lttng-sessiond/session.h

index d5b4c8db2c73484fd71571a901a5dc1b4b9633d2..7fe0f9a4b6344f35caccd8315a5746df57d5cd0e 100644 (file)
@@ -1780,10 +1780,7 @@ static int create_ust_session(struct ltt_session *session,
 
        DBG("Creating UST session");
 
-       session_lock_list();
-       uid = session_list_ptr->count;
-       session_unlock_list();
-
+       uid = session->uid;
        lus = trace_ust_create_session(session->path, uid, domain);
        if (lus == NULL) {
                ret = LTTCOMM_UST_SESS_FAIL;
index 2ab49485f738a9d3c45df96ba91baed4a397794b..bf16f76cba40a9cfeb7a71ef7e6c8cbaa30ec439 100644 (file)
@@ -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, &ltt_session_list.head);
-       ltt_session_list.count++;
+       return ++ltt_session_list.count;
 }
 
 /*
@@ -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->uid = 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 UID %d", name, path, new_session->uid);
 
        return LTTCOMM_OK;
 
index 2d077a4bc2e60e3d1cd871ae4d1bb60ac4595344..9d8bd32aa97f5e5877a91b2b6e5229447391ff2f 100644 (file)
@@ -68,6 +68,7 @@ struct ltt_session {
        pthread_mutex_t lock;
        struct cds_list_head list;
        int enabled;    /* enabled/started flag */
+       int uid;
 };
 
 /* Prototypes */
This page took 0.029502 seconds and 4 git commands to generate.