Skip to content

Commit

Permalink
Reuse connectivity check ticker (#676)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulwe authored Apr 13, 2024
1 parent 0860817 commit 0062167
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package ice
import (
"context"
"fmt"
"math"
"net"
"net/netip"
"strings"
Expand Down Expand Up @@ -372,6 +373,9 @@ func (a *Agent) connectivityChecks() {
}
}

t := time.NewTimer(math.MaxInt64)
t.Stop()

for {
interval := defaultKeepaliveInterval

Expand All @@ -392,7 +396,8 @@ func (a *Agent) connectivityChecks() {
updateInterval(a.disconnectedTimeout)
updateInterval(a.failedTimeout)

t := time.NewTimer(interval)
t.Reset(interval)

select {
case <-a.forceCandidateContact:
t.Stop()
Expand Down

0 comments on commit 0062167

Please sign in to comment.