diff options
author | Riccardo Spagni <ric@spagni.net> | 2019-03-05 14:09:42 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2019-03-05 14:09:42 +0200 |
commit | 5b9c3df5c14d420ac8bd79f12411999ce99525dd (patch) | |
tree | 55d8ef27ee48ff6d1abaa77faf31ef142f463655 | |
parent | Merge pull request #5100 (diff) | |
parent | p2p: avoid busy loop when we have nothing to connect to (diff) | |
download | monero-5b9c3df5c14d420ac8bd79f12411999ce99525dd.tar.xz |
Merge pull request #5103
ceb72be3 p2p: avoid busy loop when we have nothing to connect to (moneromooo-monero)
-rw-r--r-- | src/p2p/net_node.inl | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index e3d804086..341598e80 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -1398,7 +1398,15 @@ namespace nodetool } if(zone.second.m_net_server.is_stop_signal_sent()) return false; - conn_count = get_outgoing_connections_count(zone.second); + size_t new_conn_count = get_outgoing_connections_count(zone.second); + if (new_conn_count <= conn_count) + { + // we did not make any connection, sleep a bit to avoid a busy loop in case we don't have + // any peers to try, then break so we will try seeds to get more peers + boost::this_thread::sleep_for(boost::chrono::seconds(1)); + break; + } + conn_count = new_conn_count; } } |