Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Net] Implement poll(), fix race condition and enable p2p_timeouts.py test #2706

Merged
merged 11 commits into from
Jan 27, 2022

Commits on Jan 20, 2022

  1. Net: Fixed a race condition when disabling the network.

    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 bitcoin#13038
    lmanners authored and furszy committed Jan 20, 2022
    Configuration menu
    Copy the full SHA
    dd13d6a View commit details
    Browse the repository at this point in the history
  2. Disconnect peers which we do not receive VERACKs from within 60 sec

    And enable p2p_timeouts.py test.
    
    Coming from btc@2cbd1196b7a07b08cfd91417f2e8ddd09d9f2082 and btc@66f861ade9db108f979a9bdf8d90e8fca028e2a3
    furszy committed Jan 20, 2022
    Configuration menu
    Copy the full SHA
    63c872f View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    2beab2b View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    c35c832 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    0cb0fc7 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    8ffca91 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    af36d73 View commit details
    Browse the repository at this point in the history
  8. Move GenerateSelectSet logic to private method.

    This separates the socket event collection logic from the logic
    deciding which events we're interested in at all.
    
    Adaptation of btc@7e403c0ae705455aa66f7df9a9a99f462fd4e9a8 with further code styling corrections.
    furszy committed Jan 20, 2022
    Configuration menu
    Copy the full SHA
    d6884af View commit details
    Browse the repository at this point in the history
  9. Move SocketEvents logic to private method.

    This separates the select() logic from the socket handling logic, setting up
    for a switch to poll().
    pstratem authored and furszy committed Jan 20, 2022
    Configuration menu
    Copy the full SHA
    5c10de8 View commit details
    Browse the repository at this point in the history
  10. Implement poll() on systems which support it properly.

    This eliminates the restriction on maximum socket descriptor number.
    pstratem authored and furszy committed Jan 20, 2022
    Configuration menu
    Copy the full SHA
    e4571df View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    c9fc8cc View commit details
    Browse the repository at this point in the history