sessiond: propagate the use of ltt_session::locked_ref
[lttng-tools.git] / src / bin / lttng-sessiond / main.cpp
index 6451899cd412ea2eaf330a1a95a98366e91abb88..ee4e4690b09f2a3f0a868442caf8a67490e11a1c 100644 (file)
@@ -1279,7 +1279,7 @@ end:
 
 static void destroy_all_sessions_and_wait()
 {
-       struct ltt_session *session, *tmp;
+       struct ltt_session *raw_session_ptr, *tmp;
        struct ltt_session_list *session_list;
 
        DBG("Initiating destruction of all sessions");
@@ -1292,20 +1292,19 @@ static void destroy_all_sessions_and_wait()
        }
 
        /* Initiate the destruction of all sessions. */
-       cds_list_for_each_entry_safe (session, tmp, &session_list->head, list) {
-               if (!session_get(session)) {
-                       continue;
-               }
+       cds_list_for_each_entry_safe (raw_session_ptr, tmp, &session_list->head, list) {
+               const auto session = [raw_session_ptr]() {
+                       session_get(raw_session_ptr);
+                       raw_session_ptr->lock();
+                       return ltt_session::locked_ref(*raw_session_ptr);
+               }();
 
-               session_lock(session);
                if (session->destroyed) {
-                       goto unlock_session;
+                       continue;
                }
+
                (void) cmd_stop_trace(session);
                (void) cmd_destroy_session(session, nullptr);
-       unlock_session:
-               session_unlock(session);
-               session_put(session);
        }
 
        /* Wait for the destruction of all sessions to complete. */
This page took 0.023412 seconds and 4 git commands to generate.