mirror of
https://github.com/jech/galene.git
synced 2024-11-22 08:35:57 +01:00
Make RelayTest take the timeout as parameter.
This commit is contained in:
parent
e8bc42d84c
commit
0a8f75d6c9
2 changed files with 4 additions and 4 deletions
|
@ -130,7 +130,7 @@ func main() {
|
||||||
|
|
||||||
func relayTest() {
|
func relayTest() {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
d, err := ice.RelayTest()
|
d, err := ice.RelayTest(20 * time.Second)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Relay test failed: %v", err)
|
log.Printf("Relay test failed: %v", err)
|
||||||
log.Printf("Perhaps you didn't configure a TURN server?")
|
log.Printf("Perhaps you didn't configure a TURN server?")
|
||||||
|
|
|
@ -137,7 +137,7 @@ func ICEConfiguration() *webrtc.Configuration {
|
||||||
return &conf.conf
|
return &conf.conf
|
||||||
}
|
}
|
||||||
|
|
||||||
func RelayTest() (time.Duration, error) {
|
func RelayTest(timeout time.Duration) (time.Duration, error) {
|
||||||
|
|
||||||
conf := ICEConfiguration()
|
conf := ICEConfiguration()
|
||||||
conf2 := *conf
|
conf2 := *conf
|
||||||
|
@ -223,7 +223,7 @@ func RelayTest() (time.Duration, error) {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
timer := time.NewTimer(20 * time.Second)
|
timer := time.NewTimer(timeout)
|
||||||
defer timer.Stop()
|
defer timer.Stop()
|
||||||
select {
|
select {
|
||||||
case err := <-ch1:
|
case err := <-ch1:
|
||||||
|
@ -235,6 +235,6 @@ func RelayTest() (time.Duration, error) {
|
||||||
}
|
}
|
||||||
return time.Now().Sub(tm), nil
|
return time.Now().Sub(tm), nil
|
||||||
case <-timer.C:
|
case <-timer.C:
|
||||||
return 0, errors.New("timeout")
|
return 0, os.ErrDeadlineExceeded
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue