File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -207,8 +207,9 @@ class PeerGroupAgent implements Agent {
207207 //console.log(this.peerGroupId + ' has ' + this.getPeers().length + ' peers')
208208
209209 this . cleanUp ( ) ;
210- this . queryForOnlinePeers ( ) ;
210+ await this . queryForOnlinePeers ( ) ;
211211 this . deduplicateConnections ( ) ;
212+ await this . checkPeers ( ) ;
212213 } finally {
213214 this . tickLock . release ( ) ;
214215 }
@@ -499,6 +500,21 @@ class PeerGroupAgent implements Agent {
499500
500501 }
501502
503+ private async checkPeers ( ) {
504+ for ( const [ endpoint , connIds ] of this . connectionsPerEndpoint . entries ( ) ) {
505+ if ( await this . peerSource . getPeerForEndpoint ( endpoint ) === undefined ) {
506+ for ( const connId of connIds ) {
507+ try {
508+ this . getNetworkAgent ( ) . releaseConnectionIfExists ( connId , this . getAgentId ( ) ) ;
509+ } catch ( e ) {
510+ PeerGroupAgent . controlLog . warning ( 'Error attempting to release connection ' + connId , e ) ;
511+ }
512+ }
513+ }
514+ }
515+
516+ }
517+
502518 // Connection deduplication logic.
503519
504520 // Note: ATM the PeerGroupAgent will aggressively deduplicate all connections that go to the
You can’t perform that action at this time.
0 commit comments