Fix: The session list count should provide unique identifiers
[lttng-tools.git] / src / bin / lttng-sessiond / session.c
index bcdd78d50e68b921f47ceb4038311c625aee875d..d30f4ab197ec63b863433070cca01fb1f378ba12 100644 (file)
@@ -64,14 +64,12 @@ static unsigned int add_session_list(struct ltt_session *ls)
  * Delete a ltt_session structure to the global list.
  *
  * The caller MUST acquire the session list lock before.
+ * The session list count CANNOT be decremented, as it is used as unique
+ * identifier for the session in UST app hash table lookups.
  */
 static void del_session_list(struct ltt_session *ls)
 {
        cds_list_del(&ls->list);
-       /* Sanity check */
-       if (ltt_session_list.count > 0) {
-               ltt_session_list.count--;
-       }
 }
 
 /*
@@ -166,12 +164,6 @@ int session_create(char *name, char *path, uid_t uid, gid_t gid)
        int ret;
        struct ltt_session *new_session;
 
-       new_session = session_find_by_name(name);
-       if (new_session != NULL) {
-               ret = LTTCOMM_EXIST_SESS;
-               goto error_exist;
-       }
-
        /* Allocate session data structure */
        new_session = zmalloc(sizeof(struct ltt_session));
        if (new_session == NULL) {
@@ -214,13 +206,16 @@ int session_create(char *name, char *path, uid_t uid, gid_t gid)
        new_session->uid = uid;
        new_session->gid = gid;
 
-       ret = run_as_mkdir_recursive(new_session->path, S_IRWXU | S_IRWXG,
-                       new_session->uid, new_session->gid);
-       if (ret < 0) {
-               if (ret != -EEXIST) {
-                       ERR("Trace directory creation error");
-                       ret = LTTCOMM_CREATE_DIR_FAIL;
-                       goto error;
+       /* Mkdir if we have a valid path length */
+       if (strlen(new_session->path) > 0) {
+               ret = run_as_mkdir_recursive(new_session->path, S_IRWXU | S_IRWXG,
+                               new_session->uid, new_session->gid);
+               if (ret < 0) {
+                       if (ret != -EEXIST) {
+                               ERR("Trace directory creation error");
+                               ret = LTTCOMM_CREATE_DIR_FAIL;
+                               goto error;
+                       }
                }
        }
 
@@ -241,7 +236,6 @@ error_asprintf:
                free(new_session);
        }
 
-error_exist:
 error_malloc:
        return ret;
 }
This page took 0.023841 seconds and 4 git commands to generate.