HomePhabricator

Net: Fixed a race condition when disabling the network.

Description

Net: Fixed a race condition when disabling the network.

Summary:
This change addresses a race condition where setnetworkactive=false wouldn't always disconnect all peers.

Before this change, the following could happen:

  1. Thread A -- Begins connecting to a node.
  2. Thread B -- Sets kNetworkActive=false and disconnects connected nodes.
  3. Thread A -- Finishes connecting and adds node to list of connected nodes.

The node that was connected from Thread A remains connected and active,
even though kNetworkActive=false.

To fix the race, disconnections when kNetworkActive=false are now handled in the main network loop.

fixes #13038

This is a backport of core PR13212 and include elements of PR10824

Test Plan:

make check

Reviewers: #bitcoin_abc, jasonbcox

Reviewed By: #bitcoin_abc, jasonbcox

Subscribers: teamcity

Differential Revision: https://reviews.bitcoinabc.org/D1878

Details

Provenance
lmanners <lowellmanners@gmail.com>Authored on May 10 2018, 16:23
deadalnixCommitted on Oct 4 2018, 21:03
deadalnixPushed on Oct 4 2018, 21:15
Reviewer
Restricted Project
Differential Revision
D1878: Net: Fixed a race condition when disabling the network.
Parents
rSTAGINGa5d17df3b034: Update NSIS installation directory, regkey, icons and imagery from Bitcoin Coreā€¦
Branches
Unknown
Tags
Unknown