static void sessiond_cleanup()
{
int ret;
- struct ltt_session_list *session_list = session_get_list();
DBG("Cleanup sessiond");
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();
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, <t_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");
}
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();
}
}