From b5ce2598586d729b0906d3936706dc48e82e1455 Mon Sep 17 00:00:00 2001 From: Cecylia Bocovich Date: Thu, 5 Nov 2020 12:34:24 -0500 Subject: [PATCH] Fixed a bug that forced datachannel timeout The probetest answer response was not being sent until the select call received a datachannel timeout causing all attempted connections to fail. --- probetest/probetest.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/probetest/probetest.go b/probetest/probetest.go index af08e32..1d2d6ef 100644 --- a/probetest/probetest.go +++ b/probetest/probetest.go @@ -137,16 +137,15 @@ func probeHandler(w http.ResponseWriter, r *http.Request) { // Set a timeout on peerconnection. If the connection state has not // advanced to PeerConnectionStateConnected in this time, // destroy the peer connection and return the token. - select { - case <-dataChan: + go func() { + select { + case <-dataChan: + case <-time.After(dataChannelTimeout): + } if err := pc.Close(); err != nil { log.Printf("Error calling pc.Close: %v", err) } - case <-time.After(dataChannelTimeout): - if err := pc.Close(); err != nil { - log.Printf("Error calling pc.Close: %v", err) - } - } + }() return }