Commit e352277b authored by Dominik Charousset's avatar Dominik Charousset

Fix memory leak in group_tunnel

parent bb1a8c30
......@@ -120,15 +120,17 @@ void group_tunnel::stop() {
CAF_LOG_TRACE("");
CAF_LOG_DEBUG("stop group tunnel:" << CAF_ARG2("module", module().name())
<< CAF_ARG2("identifier", identifier_));
auto hdl = actor{};
auto worker_hdl = actor{};
auto intermediary_hdl = actor{};
auto subs = subscriber_set{};
auto cache = cached_message_list{};
auto stopped = critical_section([this, &hdl, &subs, &cache] {
auto stopped = critical_section([&, this] {
using std::swap;
if (!stopped_) {
stopped_ = true;
swap(subs, subscribers_);
swap(hdl, worker_);
swap(worker_hdl, worker_);
swap(intermediary_hdl, intermediary_);
swap(cache, cached_messages_);
return true;
} else {
......@@ -136,7 +138,7 @@ void group_tunnel::stop() {
}
});
if (stopped) {
anon_send_exit(hdl, exit_reason::user_shutdown);
anon_send_exit(worker_hdl, exit_reason::user_shutdown);
if (!subs.empty()) {
auto bye = make_message(group_down_msg{group{this}});
for (auto& sub : subs)
......
......@@ -83,8 +83,9 @@ struct testee_state {
behavior testee_impl(stateful_actor<testee_state>* self) {
return {
[=](put_atom, int x) { self->state.x = x; },
[=](get_atom) { return self->state.x; },
[self](put_atom, int x) { self->state.x = x; },
[self](get_atom) { return self->state.x; },
[self](const group_down_msg&) { self->quit(); },
};
}
......@@ -103,9 +104,11 @@ struct fixture : test_coordinator_fixture<> {
// Groups keep their subscribers alive (on purpose). Since we don't want to
// manually kill all our testee actors, we simply force the group modules to
// stop here.
uut->stop();
for (auto& kvp : uut->instances)
kvp.second->stop();
sys.groups().get_module("local")->stop();
run();
}
void make_unconnected() {
......
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