Cancel selection timeout if Agent is closed

We would always wait 10 seconds even if the ICE Agent was closed,
instead return early right when the agent is closed.

Closes pion/webrtc#897
This commit is contained in:
Sean DuBois
2019-10-24 00:02:59 -07:00
committed by Sean DuBois
parent 34ef65fcea
commit c571ca90fe
+6 -1
View File
@@ -27,7 +27,12 @@ type controllingSelector struct {
func (s *controllingSelector) Start() {
s.startTime = time.Now()
go func() {
time.Sleep(s.agent.candidateSelectionTimeout)
select {
case <-s.agent.done:
return
case <-time.After(s.agent.candidateSelectionTimeout):
}
err := s.agent.run(func(a *Agent) {
if s.nominatedPair == nil {
p := s.agent.getBestValidCandidatePair()