Skip to content

Commit

Permalink
Merge pull request #52 from libp2p/fix/51
Browse files Browse the repository at this point in the history
fix: trim connections every gracePeriod/2
  • Loading branch information
Stebalien authored Aug 2, 2021
2 parents a309beb + b200369 commit 8c67579
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion p2p/net/connmgr/connmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,15 @@ func (cm *BasicConnMgr) TrimOpenConns(ctx context.Context) {
}

func (cm *BasicConnMgr) background() {
ticker := time.NewTicker(time.Minute)
interval := cm.gracePeriod / 2
if interval < cm.silencePeriod {
interval = cm.silencePeriod
}
if interval < 10*time.Second {
interval = 10 * time.Second
}

ticker := time.NewTicker(interval)
defer ticker.Stop()

for {
Expand Down

0 comments on commit 8c67579

Please sign in to comment.