X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fbin%2Flttng-sessiond%2Fsession.c;h=d30f4ab197ec63b863433070cca01fb1f378ba12;hb=e74ecf5ad921a3edccacad4d79deb484cd19b1d5;hp=cf2ef463e8ce20404746ae7dda5a28e44f538b84;hpb=d14d33bf091e72b23b1f90ea18a0a01bed098b76;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/session.c b/src/bin/lttng-sessiond/session.c index cf2ef463e..d30f4ab19 100644 --- a/src/bin/lttng-sessiond/session.c +++ b/src/bin/lttng-sessiond/session.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include @@ -55,7 +54,7 @@ static struct ltt_session_list ltt_session_list = { * The caller MUST acquire the session list lock before. * Returns the unique identifier for the session. */ -static int add_session_list(struct ltt_session *ls) +static unsigned int add_session_list(struct ltt_session *ls) { cds_list_add(&ls->list, <t_session_list.head); return ++ltt_session_list.count; @@ -65,14 +64,12 @@ static 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--; - } } /* @@ -167,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) { @@ -215,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; + } } } @@ -230,7 +224,7 @@ int session_create(char *name, char *path, uid_t uid, gid_t gid) new_session->id = add_session_list(new_session); session_unlock_list(); - DBG("Tracing session %s created in %s with ID %d by UID %d GID %d", + DBG("Tracing session %s created in %s with ID %u by UID %d GID %d", name, path, new_session->id, new_session->uid, new_session->gid); @@ -242,7 +236,6 @@ error_asprintf: free(new_session); } -error_exist: error_malloc: return ret; }