p2p: add a couple early outs when the stop signal is received

This avoids quicker exit
This commit is contained in:
moneromooo-monero 2017-08-16 15:44:52 +01:00
parent 80d361c795
commit ef005f5e72
No known key found for this signature in database
GPG Key ID: 686F07454D6CEFC3

View File

@ -1127,6 +1127,8 @@ namespace nodetool
if (use_white_list) { if (use_white_list) {
local_peers_count = m_peerlist.get_white_peers_count(); local_peers_count = m_peerlist.get_white_peers_count();
if (!local_peers_count)
return false;
max_random_index = std::min<uint64_t>(local_peers_count -1, 20); max_random_index = std::min<uint64_t>(local_peers_count -1, 20);
random_index = get_random_index_with_fixed_probability(max_random_index); random_index = get_random_index_with_fixed_probability(max_random_index);
} else { } else {
@ -1951,6 +1953,9 @@ namespace nodetool
{ {
peerlist_entry pe = AUTO_VAL_INIT(pe); peerlist_entry pe = AUTO_VAL_INIT(pe);
if (m_net_server.is_stop_signal_sent())
return false;
if (!m_peerlist.get_random_gray_peer(pe)) { if (!m_peerlist.get_random_gray_peer(pe)) {
return false; return false;
} }