[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [snowflake/master] Fix for ticket #30206
commit 695dd10b2c7a1b0c1227d024e3784e2a3207bc6c
Author: Cecylia Bocovich <cohosh@xxxxxxxxxxxxxx>
Date: Fri Apr 26 13:27:20 2019 -0400
Fix for ticket #30206
This fixes a bug introduced by the deadlock patch for ticket #25688.
---
proxy-go/snowflake.go | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/proxy-go/snowflake.go b/proxy-go/snowflake.go
index dda9a9a..12190ac 100644
--- a/proxy-go/snowflake.go
+++ b/proxy-go/snowflake.go
@@ -30,7 +30,7 @@ const pollInterval = 5 * time.Second
//amount of time after sending an SDP answer before the proxy assumes the
//client is not going to connect
-const dataChannelTimeout = time.Minute
+const dataChannelTimeout = 20 * time.Second
var brokerURL *url.URL
var relayURL string
@@ -265,6 +265,7 @@ func datachannelHandler(conn *webRTCConn, remoteAddr net.Addr) {
// datachannelHandler.
func makePeerConnectionFromOffer(sdp *webrtc.SessionDescription, config *webrtc.Configuration) (*webrtc.PeerConnection, error) {
+ dataChan := make(chan struct{})
pc, err := webrtc.NewPeerConnection(config)
if err != nil {
return nil, fmt.Errorf("accept: NewPeerConnection: %s", err)
@@ -274,6 +275,7 @@ func makePeerConnectionFromOffer(sdp *webrtc.SessionDescription, config *webrtc.
}
pc.OnDataChannel = func(dc *webrtc.DataChannel) {
log.Println("OnDataChannel")
+ close(dataChan)
pr, pw := io.Pipe()
conn := &webRTCConn{pc: pc, dc: dc, pr: pr}
@@ -335,9 +337,11 @@ func makePeerConnectionFromOffer(sdp *webrtc.SessionDescription, config *webrtc.
// advanced to PeerConnectionStateConnected in this time,
// destroy the peer connection and return the token.
go func() {
- <-time.After(dataChannelTimeout)
- if pc.ConnectionState() != webrtc.PeerConnectionStateConnected {
- log.Println("Timed out waiting for client to open data cannel.")
+ select {
+ case <-dataChan:
+ log.Println("Connection successful.")
+ case <-time.After(dataChannelTimeout):
+ log.Println("Timed out waiting for client to open data channel.")
pc.Destroy()
retToken()
}
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits