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

Fix shutdown behavior of actor pools

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