Commit 72e58355 authored by Dominik Charousset's avatar Dominik Charousset

Fix shutdown behavior of actor pools

parent b2291430
......@@ -102,8 +102,10 @@ public:
actor_pool(actor_config& cfg);
void on_destroy() override;
protected:
void on_cleanup() override;
void on_cleanup(const error& reason) override;
private:
bool filter(upgrade_lock<detail::shared_spinlock>&,
......
......@@ -47,7 +47,7 @@ public:
message_types_set message_types() const override;
protected:
void on_cleanup() override;
void on_cleanup(const error& reason) override;
private:
strong_actor_ptr f_;
......
......@@ -104,7 +104,7 @@ protected:
/// Allows subclasses to add additional cleanup code to the
/// critical secion in `cleanup`. This member function is
/// called inside of a critical section.
virtual void on_cleanup();
virtual void on_cleanup(const error& reason);
/// Sends a response message if `what` is a request.
void bounce(mailbox_element_ptr& what);
......
......@@ -126,8 +126,19 @@ actor_pool::actor_pool(actor_config& cfg) : monitorable_actor(cfg) {
register_at_system();
}
void actor_pool::on_cleanup() {
// nop
void actor_pool::on_destroy() {
CAF_PUSH_AID_FROM_PTR(this);
if (!getf(is_cleaned_up_flag)) {
cleanup(exit_reason::unreachable, nullptr);
monitorable_actor::on_destroy();
unregister_from_system();
}
}
void actor_pool::on_cleanup(const error& reason) {
CAF_PUSH_AID_FROM_PTR(this);
CAF_IGNORE_UNUSED(reason);
CAF_LOG_TERMINATE_EVENT(this, reason);
}
bool actor_pool::filter(upgrade_lock<detail::shared_spinlock>& guard,
......
......@@ -119,9 +119,9 @@ bool local_actor::cleanup(error&& fail_state, execution_unit* host) {
CAF_LOG_TRACE(CAF_ARG(fail_state));
// tell registry we're done
unregister_from_system();
CAF_LOG_TERMINATE_EVENT(this, fail_state);
monitorable_actor::cleanup(std::move(fail_state), host);
clock().cancel_timeouts(this);
CAF_LOG_TERMINATE_EVENT(this, fail_state);
return true;
}
......
......@@ -82,7 +82,7 @@ bool monitorable_actor::cleanup(error&& reason, execution_unit* host) {
fail_state_ = std::move(reason);
attachables_head_.swap(head);
flags(flags() | is_terminated_flag | is_cleaned_up_flag);
on_cleanup();
on_cleanup(fail_state_);
return true;
}
return false;
......@@ -104,7 +104,7 @@ bool monitorable_actor::cleanup(error&& reason, execution_unit* host) {
return true;
}
void monitorable_actor::on_cleanup() {
void monitorable_actor::on_cleanup(const error&) {
// nop
}
......
......@@ -76,7 +76,7 @@ sequencer::message_types_set sequencer::message_types() const {
return msg_types_;
}
void sequencer::on_cleanup() {
void sequencer::on_cleanup(const error&) {
f_.reset();
g_.reset();
}
......
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