diff options
author | Howard Chu <hyc@symas.com> | 2017-06-04 22:37:53 +0100 |
---|---|---|
committer | Howard Chu <hyc@symas.com> | 2017-06-15 16:54:03 +0100 |
commit | 07c4276cbebe453f552dd107a72d7231579dea57 (patch) | |
tree | 3fe8ef7ef34c029083d0fb7bb0f80d850ad5216d /src/p2p | |
parent | Don't timeout a slow operation that's making progress (diff) | |
download | monero-07c4276cbebe453f552dd107a72d7231579dea57.tar.xz |
Don't issue a new timedsync while one is already in progress
A timedsync is issued every minute on a connection, but the input
tineout is 2 minutes. This means a new sync request could be issued
while a slow sync request was already in progress. The additional
request will further clog the network on a slow connection, and
cause a premature timeout.
Diffstat (limited to 'src/p2p')
-rw-r--r-- | src/p2p/net_node.inl | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index 5c903b1f5..0d0d86e14 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -814,6 +814,7 @@ namespace nodetool bool r = epee::net_utils::async_invoke_remote_command2<typename COMMAND_TIMED_SYNC::response>(context_.m_connection_id, COMMAND_TIMED_SYNC::ID, arg, m_net_server.get_config_object(), [this](int code, const typename COMMAND_TIMED_SYNC::response& rsp, p2p_connection_context& context) { + context.m_in_timedsync = false; if(code < 0) { LOG_ERROR_CC(context, "COMMAND_TIMED_SYNC invoke failed. (" << code << ", " << epee::levin::get_err_descr(code) << ")"); @@ -1300,10 +1301,13 @@ namespace nodetool MDEBUG("STARTED PEERLIST IDLE HANDSHAKE"); typedef std::list<std::pair<epee::net_utils::connection_context_base, peerid_type> > local_connects_type; local_connects_type cncts; - m_net_server.get_config_object().foreach_connection([&](const p2p_connection_context& cntxt) + m_net_server.get_config_object().foreach_connection([&](p2p_connection_context& cntxt) { - if(cntxt.peer_id) + if(cntxt.peer_id && !cntxt.m_in_timedsync) + { + cntxt.m_in_timedsync = true; cncts.push_back(local_connects_type::value_type(cntxt, cntxt.peer_id));//do idle sync only with handshaked connections + } return true; }); |