aboutsummaryrefslogtreecommitdiff
path: root/src/p2p/net_node.inl
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2020-12-04 13:32:32 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2020-12-06 12:40:07 +0000
commit281b42a281f275b5cc4a5c49336a94cedd0e3ae5 (patch)
tree849efc84a8f2476de396414a6ab055e635cca048 /src/p2p/net_node.inl
parentMerge pull request #7058 (diff)
downloadmonero-281b42a281f275b5cc4a5c49336a94cedd0e3ae5.tar.xz
p2p: fix race condition accessing a deleted context
Diffstat (limited to 'src/p2p/net_node.inl')
-rw-r--r--src/p2p/net_node.inl16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl
index 93a925971..bc05bba29 100644
--- a/src/p2p/net_node.inl
+++ b/src/p2p/net_node.inl
@@ -224,7 +224,7 @@ namespace nodetool
}
//-----------------------------------------------------------------------------------
template<class t_payload_net_handler>
- bool node_server<t_payload_net_handler>::block_host(const epee::net_utils::network_address &addr, time_t seconds)
+ bool node_server<t_payload_net_handler>::block_host(epee::net_utils::network_address addr, time_t seconds)
{
if(!addr.is_blockable())
return false;
@@ -237,7 +237,8 @@ namespace nodetool
limit = std::numeric_limits<time_t>::max();
else
limit = now + seconds;
- m_blocked_hosts[addr.host_str()] = limit;
+ const std::string host_str = addr.host_str();
+ m_blocked_hosts[host_str] = limit;
// drop any connection to that address. This should only have to look into
// the zone related to the connection, but really make sure everything is
@@ -253,17 +254,18 @@ namespace nodetool
}
return true;
});
- for (const auto &c: conns)
- zone.second.m_net_server.get_config_object().close(c);
-
- conns.clear();
peerlist_entry pe{};
pe.adr = addr;
zone.second.m_peerlist.remove_from_peer_white(pe);
+
+ for (const auto &c: conns)
+ zone.second.m_net_server.get_config_object().close(c);
+
+ conns.clear();
}
- MCLOG_CYAN(el::Level::Info, "global", "Host " << addr.host_str() << " blocked.");
+ MCLOG_CYAN(el::Level::Info, "global", "Host " << host_str << " blocked.");
return true;
}
//-----------------------------------------------------------------------------------