Fix Controlled agent candidate selection timeout

Before if Controlled side never got any candidates
it would never properly shut down. We never checked
the start time against candidateSelectionTimeout

Resolves pion/webrtc#854
This commit is contained in:
Aaron France
2019-10-05 23:03:22 -07:00
committed by Sean DuBois
parent b0ac6d9c37
commit 377e52e387
+13 -5
View File
@@ -190,11 +190,14 @@ func (s *controllingSelector) PingCandidate(local, remote Candidate) {
}
type controlledSelector struct {
agent *Agent
log logging.LeveledLogger
startTime time.Time
agent *Agent
log logging.LeveledLogger
}
func (s *controlledSelector) Start() {}
func (s *controlledSelector) Start() {
s.startTime = time.Now()
}
func (s *controlledSelector) ContactCandidates() {
if s.agent.selectedPair != nil {
@@ -203,8 +206,13 @@ func (s *controlledSelector) ContactCandidates() {
s.agent.checkKeepalive()
}
} else {
s.log.Trace("pinging all candidates")
s.agent.pingAllCandidates()
if time.Since(s.startTime) > s.agent.candidateSelectionTimeout {
s.log.Trace("check timeout reached and no valid candidate pair found, marking connection as failed")
s.agent.updateConnectionState(ConnectionStateFailed)
} else {
s.log.Trace("pinging all candidates")
s.agent.pingAllCandidates()
}
}
}