-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
manager: Fix connection limits tracking of rejected connections (#286)
This PR ensures that connection IDs are properly tracked to enforce connection limits. After ~1/2 days the substrate litep2p running node is starting to reject multiple pending socket connections. This is related to the fact that accepting of established connection is a two-part process: - step 1. Can we accept the connection based on number of connections? - step 2. The transport manager transitions the peer state - step 3. If the transition succeeds, the connection is tracked (inserted in a hashmap). If step 2 fails, we were previously leaking the connection ID. The connection ID is also counting towards the maximum number of connections the node can sustain. This PR effectively modifies the connection limits API, `on_connection_established` is split into two methods: - `can_accept_connection()` - `accept_established_connection()` This fixes a subtle memory leak bounded at 10000 Connection IDs. However, even more important, this fixes connection stability for long-running nodes. Discovered during the investigation of: - #282 cc @paritytech/networking --------- Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
- Loading branch information
Showing
2 changed files
with
33 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters