mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
net: Block v2->v1 transport downgrade if !CConnman::fNetworkActive
We might have just set CNode::fDisconnect in the first loop because of being offline. Also caches CConnman::fNetworkActive in case it's changed concurrently with our own thread.
This commit is contained in:
parent
698f86964c
commit
6869fb4170
1 changed files with 3 additions and 2 deletions
|
@ -1910,7 +1910,8 @@ void CConnman::DisconnectNodes()
|
|||
{
|
||||
LOCK(m_nodes_mutex);
|
||||
|
||||
if (!fNetworkActive) {
|
||||
const bool network_active{fNetworkActive};
|
||||
if (!network_active) {
|
||||
// Disconnect any connected nodes
|
||||
for (CNode* pnode : m_nodes) {
|
||||
if (!pnode->fDisconnect) {
|
||||
|
@ -1932,7 +1933,7 @@ void CConnman::DisconnectNodes()
|
|||
// Add to reconnection list if appropriate. We don't reconnect right here, because
|
||||
// the creation of a connection is a blocking operation (up to several seconds),
|
||||
// and we don't want to hold up the socket handler thread for that long.
|
||||
if (pnode->m_transport->ShouldReconnectV1()) {
|
||||
if (network_active && pnode->m_transport->ShouldReconnectV1()) {
|
||||
reconnections_to_add.push_back({
|
||||
.addr_connect = pnode->addr,
|
||||
.grant = std::move(pnode->grantOutbound),
|
||||
|
|
Loading…
Add table
Reference in a new issue