Use compiler-agnostic defines to silence warning
[lttng-tools.git] / src / bin / lttng-sessiond / main.cpp
index 3e5d8eeeaca01791c742ca2d4c58fa3f733c14fb..0902969e71dee38b7319e007329e823e785afdc6 100644 (file)
@@ -277,7 +277,6 @@ static void wait_consumer(struct consumer_data *consumer_data)
 static void sessiond_cleanup()
 {
        int ret;
-       struct ltt_session_list *session_list = session_get_list();
 
        DBG("Cleanup sessiond");
 
@@ -327,8 +326,6 @@ static void sessiond_cleanup()
        DBG("Removing directory %s", the_config.consumerd64_path.value);
        (void) rmdir(the_config.consumerd64_path.value);
 
-       pthread_mutex_destroy(&session_list->lock);
-
        DBG("Cleaning up all per-event notifier domain agents");
        agent_by_event_notifier_domain_ht_destroy();
 
@@ -1282,38 +1279,38 @@ end:
 
 static void destroy_all_sessions_and_wait()
 {
-       struct ltt_session *session, *tmp;
        struct ltt_session_list *session_list;
 
-       session_list = session_get_list();
        DBG("Initiating destruction of all sessions");
 
+       auto list_lock = lttng::sessiond::lock_session_list();
+
+       session_list = session_get_list();
        if (!session_list) {
                return;
        }
 
-       session_lock_list();
        /* Initiate the destruction of all sessions. */
-       cds_list_for_each_entry_safe (session, tmp, &session_list->head, list) {
-               if (!session_get(session)) {
-                       continue;
-               }
+       for (auto raw_session_ptr :
+            lttng::urcu::list_iteration_adapter<ltt_session, &ltt_session::list>(
+                    session_list->head)) {
+               const auto session = [raw_session_ptr]() {
+                       session_get(raw_session_ptr);
+                       raw_session_ptr->lock();
+                       return ltt_session::make_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);
        }
-       session_unlock_list();
 
        /* Wait for the destruction of all sessions to complete. */
        DBG("Waiting for the destruction of all sessions to complete");
-       session_list_wait_empty();
+       session_list_wait_empty(std::move(list_lock));
        DBG("Destruction of all sessions completed");
 }
 
@@ -1982,7 +1979,7 @@ int main(int argc, char **argv)
        try {
                return _main(argc, argv);
        } catch (const std::exception& e) {
-               ERR_FMT("Unhandled exception caught by main thread: %s", e.what());
+               ERR_FMT("Unhandled exception caught by main thread: {}", e.what());
                abort();
        }
 }
This page took 0.024244 seconds and 4 git commands to generate.