aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_protocol/cryptonote_protocol_handler.inl
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-10-19 15:48:46 +0100
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-10-22 19:45:30 +0100
commit1ff638e927cf66e9dd9e685f956526249a82beb4 (patch)
treef0c28f7eef35ceaf5e8520161032c0c73a35175a /src/cryptonote_protocol/cryptonote_protocol_handler.inl
parentMerge pull request #2601 (diff)
downloadmonero-1ff638e927cf66e9dd9e685f956526249a82beb4.tar.xz
protocol: drop connections which don't handshake after some time
Diffstat (limited to 'src/cryptonote_protocol/cryptonote_protocol_handler.inl')
-rw-r--r--src/cryptonote_protocol/cryptonote_protocol_handler.inl9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.inl b/src/cryptonote_protocol/cryptonote_protocol_handler.inl
index d16e5d7e5..e41491954 100644
--- a/src/cryptonote_protocol/cryptonote_protocol_handler.inl
+++ b/src/cryptonote_protocol/cryptonote_protocol_handler.inl
@@ -52,6 +52,7 @@
#define BLOCK_QUEUE_SIZE_THRESHOLD (100*1024*1024) // MB
#define REQUEST_NEXT_SCHEDULED_SPAN_THRESHOLD (5 * 1000000) // microseconds
#define IDLE_PEER_KICK_TIME (600 * 1000000) // microseconds
+#define PASSIVE_PEER_KICK_TIME (60 * 1000000) // microseconds
namespace cryptonote
{
@@ -1184,13 +1185,15 @@ skip:
std::vector<boost::uuids::uuid> kick_connections;
m_p2p->for_each_connection([&](cryptonote_connection_context& context, nodetool::peerid_type peer_id, uint32_t support_flags)->bool
{
- if (context.m_state == cryptonote_connection_context::state_synchronizing)
+ if (context.m_state == cryptonote_connection_context::state_synchronizing || context.m_state == cryptonote_connection_context::state_before_handshake)
{
+ const bool passive = context.m_state == cryptonote_connection_context::state_before_handshake;
const boost::posix_time::ptime now = boost::posix_time::microsec_clock::universal_time();
const boost::posix_time::time_duration dt = now - context.m_last_request_time;
- if (dt.total_microseconds() > IDLE_PEER_KICK_TIME)
+ const int64_t threshold = passive ? PASSIVE_PEER_KICK_TIME : IDLE_PEER_KICK_TIME;
+ if (dt.total_microseconds() > threshold)
{
- MINFO(context << " kicking idle peer");
+ MINFO(context << " kicking " << (passive ? "passive" : "idle") << " peer");
kick_connections.push_back(context.m_connection_id);
}
}