Commit 50443a0e authored by Dominik Charousset's avatar Dominik Charousset Committed by Dominik Charousset

Call remove_from_loop in manager::detach

The detach() function gets called from the multiplexer when an error
occurs or from the broker when closing this manager. In both cases, we
need to make sure this manager does not receive further socket events.
Relates #695.
parent b332a1ad
...@@ -43,11 +43,16 @@ abstract_broker* manager::parent() { ...@@ -43,11 +43,16 @@ abstract_broker* manager::parent() {
} }
void manager::detach(execution_unit*, bool invoke_disconnect_message) { void manager::detach(execution_unit*, bool invoke_disconnect_message) {
CAF_LOG_TRACE(""); CAF_LOG_TRACE(CAF_ARG(invoke_disconnect_message));
// This function gets called from the multiplexer when an error occurs or
// from the broker when closing this manager. In both cases, we need to make
// sure this manager does not receive further socket events.
remove_from_loop();
// Disconnect from the broker if not already detached.
if (!detached()) { if (!detached()) {
CAF_LOG_DEBUG("disconnect servant from broker"); CAF_LOG_DEBUG("disconnect servant from broker");
auto raw_ptr = parent(); auto raw_ptr = parent();
// keep the strong reference until we go out of scope // Keep a strong reference to our parent until we go out of scope.
strong_actor_ptr ptr; strong_actor_ptr ptr;
ptr.swap(parent_); ptr.swap(parent_);
detach_from(raw_ptr); detach_from(raw_ptr);
...@@ -69,6 +74,12 @@ void manager::detach(execution_unit*, bool invoke_disconnect_message) { ...@@ -69,6 +74,12 @@ void manager::detach(execution_unit*, bool invoke_disconnect_message) {
} }
} }
void manager::io_failure(execution_unit* ctx, operation op) {
CAF_LOG_TRACE(CAF_ARG(op));
CAF_IGNORE_UNUSED(op);
detach(ctx, true);
}
} // namespace network } // namespace network
} // namespace io } // namespace io
} // namespace caf } // namespace caf
...@@ -196,8 +196,6 @@ void stream::handle_error_propagation() { ...@@ -196,8 +196,6 @@ void stream::handle_error_propagation() {
reader_->io_failure(&backend(), operation::read); reader_->io_failure(&backend(), operation::read);
if (writer_) if (writer_)
writer_->io_failure(&backend(), operation::write); writer_->io_failure(&backend(), operation::write);
// backend will delete this handler anyway,
// no need to call backend().del() here
} }
} // namespace network } // namespace network
......
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