Commit e4ec7c59 authored by Dominik Charousset's avatar Dominik Charousset

Fix memory leak during shutdown

parent 272db974
......@@ -244,8 +244,12 @@ void actor_registry::initialize() {
}
};
};
// NOTE: all actors that we spawn here *must not* access the scheduler,
// because the scheduler will make sure that the registry is running
// as part of its initialization; hence, all actors have to
// use the lazy_init flag
named_entries_.emplace(atom("SpawnServ"), spawn_announce_actor_type_server());
named_entries_.emplace(atom("ConfigServ"), spawn<hidden>(kvstore));
named_entries_.emplace(atom("ConfigServ"), spawn<hidden+lazy_init>(kvstore));
}
} // namespace detail
......
......@@ -116,13 +116,23 @@ group_manager* singletons::get_group_manager() {
}
scheduler::abstract_coordinator* singletons::get_scheduling_coordinator() {
return lazy_get(s_scheduling_coordinator, s_scheduling_coordinator_mtx);
// when creating the scheduler, make sure the registry
// is in place as well, because our shutdown sequence assumes
// a certain order for stopping singletons
auto f = []() -> scheduler::abstract_coordinator* {
get_actor_registry();
return scheduler::abstract_coordinator::create_singleton();
};
return lazy_get(s_scheduling_coordinator, s_scheduling_coordinator_mtx, f);
}
bool singletons::set_scheduling_coordinator(scheduler::abstract_coordinator*p) {
auto res = lazy_get(s_scheduling_coordinator, s_scheduling_coordinator_mtx,
[p] { return p; });
return res == p;
auto f = [p]() -> scheduler::abstract_coordinator* {
get_actor_registry(); // see comment above
return p;
};
auto x = lazy_get(s_scheduling_coordinator, s_scheduling_coordinator_mtx, f);
return x == p;
}
node_id singletons::get_node_id() {
......
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