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

Conversation

furszy
Copy link

@furszy furszy commented Jan 3, 2022

More tier two p2p network required updates. Focused mainly on porting the sockets poll functionality to eliminate the maximum socket descriptor number restriction.

Following points tackled:

  1. Backported Net: Fixed a race condition when disabling the network. bitcoin/bitcoin#13212 to fix a race condition on the network disable process.

  2. Disconnect peers that have not send a VERACKs for more than 60 secs (coming from 2cbd119), and enabled the p2p_timeouts.py functional test which validates the functionality.

  3. Implement sockets poll functionality:

@furszy furszy self-assigned this Jan 3, 2022
@furszy furszy changed the title [Net] Implement poll(), fix race condition and enable p2p_timeouts.py test [WIP][Net] Implement poll(), fix race condition and enable p2p_timeouts.py test Jan 3, 2022
@furszy furszy added this to the 6.0.0 milestone Jan 3, 2022
@furszy furszy added the P2P label Jan 3, 2022
@furszy furszy changed the title [WIP][Net] Implement poll(), fix race condition and enable p2p_timeouts.py test [Net] Implement poll(), fix race condition and enable p2p_timeouts.py test Jan 4, 2022
@furszy
Copy link
Author

furszy commented Jan 19, 2022

rebased on master, ready to go.

lmanners and others added 11 commits January 20, 2022 20:05
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
And enable p2p_timeouts.py test.

Coming from btc@2cbd1196b7a07b08cfd91417f2e8ddd09d9f2082 and btc@66f861ade9db108f979a9bdf8d90e8fca028e2a3
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.
This separates the select() logic from the socket handling logic, setting up
for a switch to poll().
This eliminates the restriction on maximum socket descriptor number.
Copy link

@random-zebra random-zebra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK c9fc8cc

Copy link
Collaborator

@Fuzzbawls Fuzzbawls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK c9fc8cc

@furszy furszy merged commit f2ec569 into PIVX-Project:master Jan 27, 2022
@Fuzzbawls Fuzzbawls modified the milestones: 6.0.0, 5.5.0 Sep 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants