X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fsession.cpp;h=64fd19d04485023815f73ed27adb9a6abcf914e7;hp=0d19042b594f8edfda6817a866cf6931378a8b4b;hb=ed41e5709047ef545aa28082416e641e003b45e0;hpb=a49a92168370faa70db89ec73b41fbcb7af531e8 diff --git a/src/bin/lttng-sessiond/session.cpp b/src/bin/lttng-sessiond/session.cpp index 0d19042b5..64fd19d04 100644 --- a/src/bin/lttng-sessiond/session.cpp +++ b/src/bin/lttng-sessiond/session.cpp @@ -398,7 +398,7 @@ end: } /* - * Remove a ltt_session from the ltt_sessions_ht_by_id/name. + * Remove a ltt_session from the ltt_sessions_ht_by_id. * If empty, the ltt_sessions_ht_by_id/name HTs are freed. * The session list lock must be held. */ @@ -415,10 +415,6 @@ static void del_session_ht(struct ltt_session *ls) ret = lttng_ht_del(ltt_sessions_ht_by_id, &iter); LTTNG_ASSERT(!ret); - iter.iter.node = &ls->node_by_name.node; - ret = lttng_ht_del(ltt_sessions_ht_by_name, &iter); - LTTNG_ASSERT(!ret); - if (ltt_sessions_ht_empty()) { DBG("Empty ltt_sessions_ht_by_id/name, destroying hast tables"); ltt_sessions_ht_destroy(); @@ -1065,8 +1061,23 @@ void session_put(struct ltt_session *session) */ void session_destroy(struct ltt_session *session) { + int ret; + struct lttng_ht_iter iter; + LTTNG_ASSERT(!session->destroyed); session->destroyed = true; + + /* + * Remove immediately from the "session by name" hash table. Only one + * session is expected to exist with a given name for at any given time. + * + * Even if a session still technically exists for a little while longer, + * there is no point in performing action on a "destroyed" session. + */ + iter.iter.node = &session->node_by_name.node; + ret = lttng_ht_del(ltt_sessions_ht_by_name, &iter); + LTTNG_ASSERT(!ret); + session_put(session); }