Commit 076112c8 authored by Dominik Charousset's avatar Dominik Charousset

Fix handling of connection fails during handshake

parent 1003c017
...@@ -118,8 +118,10 @@ struct basp_broker_state : proxy_registry::backend, basp::instance::callee { ...@@ -118,8 +118,10 @@ struct basp_broker_state : proxy_registry::backend, basp::instance::callee {
// protocol instance of BASP // protocol instance of BASP
basp::instance instance; basp::instance instance;
using ctx_map = std::unordered_map<connection_handle, connection_context>;
// keeps context information for all open connections // keeps context information for all open connections
std::unordered_map<connection_handle, connection_context> ctx; ctx_map ctx;
// points to the current context for callbacks such as `make_proxy` // points to the current context for callbacks such as `make_proxy`
connection_context* this_context = nullptr; connection_context* this_context = nullptr;
......
...@@ -603,10 +603,25 @@ behavior basp_broker::make_behavior() { ...@@ -603,10 +603,25 @@ behavior basp_broker::make_behavior() {
// hops to be resilient to (rare) network failures or if a // hops to be resilient to (rare) network failures or if a
// node is reachable via several interfaces and only one fails // node is reachable via several interfaces and only one fails
auto nid = state.instance.tbl().lookup_direct(msg.handle); auto nid = state.instance.tbl().lookup_direct(msg.handle);
// tell BASP instance we've lost connection if (nid != none) {
state.instance.handle_node_shutdown(nid); // tell BASP instance we've lost connection
CAF_ASSERT(nid == none state.instance.handle_node_shutdown(nid);
|| !state.instance.tbl().reachable(nid)); } else {
// check whether the connection failed during handshake
auto pred = [&](const basp_broker_state::ctx_map::value_type& x) {
return x.second.hdl == msg.handle;
};
auto e = state.ctx.end();
auto i = std::find_if(state.ctx.begin(), e, pred);
if (i != e) {
auto& ref = i->second;
if (ref.callback) {
CAF_LOG_DEBUG("connection closed during handshake");
ref.callback->deliver(sec::disconnect_during_handshake);
}
state.ctx.erase(i);
}
}
}, },
// received from underlying broker implementation // received from underlying broker implementation
[=](const acceptor_closed_msg& msg) { [=](const acceptor_closed_msg& msg) {
......
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