Closed achingbrain closed 2 months ago
would like to hear the rationale behind the changes.
If we do something like a DHT query, we open a connection to a peer, open a /ipfs/kad/1.0.0
stream, send a message and read the response. We do this repeatedly and eventually hit the max connections limit. The pruner tries to close some connections to bring us back under the limit while we're trying to continue the query.
The older connections are less useful now, since that peer plays no further part in the query. The more useful connections are the ones we're trying to open to continue the query - these are the newest connections so right now would be the ones that get closed by the pruner, almost immediately after being opened. Oops.
Instead, we should look for connections that have no open streams - these are safe(r) to close because no protocol is using them.
Thanks for the clarification
Changes how we sort connections to prune to be more than just tags and age.
Now we'll sort by tags, the number of open streams, direction and age.
This should choose idle connections without streams to close over those that are in use.
Change checklist