diff options
author | luigi1111 <luigi1111w@gmail.com> | 2020-04-04 12:32:05 -0500 |
---|---|---|
committer | luigi1111 <luigi1111w@gmail.com> | 2020-04-04 12:32:05 -0500 |
commit | 8f59b0ed14bc0acb21f24491c0413df6234afb25 (patch) | |
tree | 79d5407aa6b29fce958fdebe05bd10f5c7047ab6 /src | |
parent | Merge pull request #6336 (diff) | |
parent | p2p: fix frequent weak_ptr exception on connection (diff) | |
download | monero-8f59b0ed14bc0acb21f24491c0413df6234afb25.tar.xz |
Merge pull request #6269
21fe6a2 p2p: fix frequent weak_ptr exception on connection (moneromooo-monero)
Diffstat (limited to '')
-rw-r--r-- | src/p2p/net_node.inl | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index 9b6358dee..dcd16e5c1 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -1013,15 +1013,18 @@ namespace nodetool epee::simple_event ev; std::atomic<bool> hsh_result(false); + bool timeout = false; bool r = epee::net_utils::async_invoke_remote_command2<typename COMMAND_HANDSHAKE::response>(context_, COMMAND_HANDSHAKE::ID, arg, zone.m_net_server.get_config_object(), - [this, &pi, &ev, &hsh_result, &just_take_peerlist, &context_](int code, const typename COMMAND_HANDSHAKE::response& rsp, p2p_connection_context& context) + [this, &pi, &ev, &hsh_result, &just_take_peerlist, &context_, &timeout](int code, const typename COMMAND_HANDSHAKE::response& rsp, p2p_connection_context& context) { epee::misc_utils::auto_scope_leave_caller scope_exit_handler = epee::misc_utils::create_scope_leave_handler([&](){ev.raise();}); if(code < 0) { LOG_WARNING_CC(context, "COMMAND_HANDSHAKE invoke failed. (" << code << ", " << epee::levin::get_err_descr(code) << ")"); + if (code == LEVIN_ERROR_CONNECTION_TIMEDOUT || code == LEVIN_ERROR_CONNECTION_DESTROYED) + timeout = true; return; } @@ -1079,7 +1082,8 @@ namespace nodetool if(!hsh_result) { LOG_WARNING_CC(context_, "COMMAND_HANDSHAKE Failed"); - m_network_zones.at(context_.m_remote_address.get_zone()).m_net_server.get_config_object().close(context_.m_connection_id); + if (!timeout) + zone.m_net_server.get_config_object().close(context_.m_connection_id); } else if (!just_take_peerlist) { @@ -1266,7 +1270,6 @@ namespace nodetool LOG_PRINT_CC_PRIORITY_NODE(is_priority, *con, "Failed to HANDSHAKE with peer " << na.str() /*<< ", try " << try_count*/); - zone.m_net_server.get_config_object().close(con->m_connection_id); record_addr_failed(na); return false; } @@ -1330,7 +1333,6 @@ namespace nodetool bool is_priority = is_priority_node(na); LOG_PRINT_CC_PRIORITY_NODE(is_priority, *con, "Failed to HANDSHAKE with peer " << na.str()); - zone.m_net_server.get_config_object().close(con->m_connection_id); record_addr_failed(na); return false; } |