Commit a4df55f6 authored by Dominik Charousset's avatar Dominik Charousset

Do not detach middleman actor, stop scheduler last

Detaching `middleman_actor_impl` made little sense to begin with. Since the
actor is hidden, there is also the risk of running into a "heap-use-after-free"
bug when detaching it (shutdown has no way to detect whether hidden actors are
still alive before disposing all singletons). Stopping the scheduler *after*
all plugins (e.g. middleman) and the group module makes sure that hidden actors
are allowed to run their cleanup code.
parent 61fb6752
...@@ -69,14 +69,14 @@ std::mutex& singletons::get_plugin_mutex() { ...@@ -69,14 +69,14 @@ std::mutex& singletons::get_plugin_mutex() {
void singletons::stop_singletons() { void singletons::stop_singletons() {
// stop singletons, i.e., make sure no background threads/actors are running // stop singletons, i.e., make sure no background threads/actors are running
CAF_LOGF_DEBUG("stop group manager");
stop(s_group_manager);
CAF_LOGF_DEBUG("stop scheduler");
stop(s_scheduling_coordinator);
CAF_LOGF_DEBUG("stop plugins"); CAF_LOGF_DEBUG("stop plugins");
for (auto& plugin : s_plugins) { for (auto& plugin : s_plugins) {
stop(plugin); stop(plugin);
} }
CAF_LOGF_DEBUG("stop group manager");
stop(s_group_manager);
CAF_LOGF_DEBUG("stop scheduler");
stop(s_scheduling_coordinator);
CAF_LOGF_DEBUG("stop actor registry"); CAF_LOGF_DEBUG("stop actor registry");
stop(s_actor_registry); stop(s_actor_registry);
CAF_LOGF_DEBUG("stop type info map"); CAF_LOGF_DEBUG("stop type info map");
......
...@@ -362,7 +362,7 @@ void middleman::initialize() { ...@@ -362,7 +362,7 @@ void middleman::initialize() {
do_announce<new_connection_msg>("caf::io::new_connection_msg"); do_announce<new_connection_msg>("caf::io::new_connection_msg");
do_announce<new_data_msg>("caf::io::new_data_msg"); do_announce<new_data_msg>("caf::io::new_data_msg");
actor mgr = get_named_broker<basp_broker>(atom("_BASP")); actor mgr = get_named_broker<basp_broker>(atom("_BASP"));
m_manager = spawn_typed<middleman_actor_impl, detached + hidden>(*this, mgr); m_manager = spawn_typed<middleman_actor_impl, hidden>(*this, mgr);
} }
void middleman::stop() { void middleman::stop() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment