This is an automated email from the git hooks/post-receive script.
cohosh pushed a commit to branch main in repository pluggable-transports/snowflake.
commit b010de5abb89aba37da73e50eb5c7dbe054c4362 Author: Cecylia Bocovich cohosh@torproject.org AuthorDate: Wed Oct 19 10:05:18 2022 -0400
Terminate timeoutLoop when conn is closed --- proxy/lib/webrtcconn.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/proxy/lib/webrtcconn.go b/proxy/lib/webrtcconn.go index c243449..40b26c9 100644 --- a/proxy/lib/webrtcconn.go +++ b/proxy/lib/webrtcconn.go @@ -35,12 +35,14 @@ type webRTCConn struct {
inactivityTimeout time.Duration activity chan struct{} + closed chan struct{} }
func newWebRTCConn(pc *webrtc.PeerConnection, dc *webrtc.DataChannel, pr *io.PipeReader, eventLogger event.SnowflakeEventReceiver) *webRTCConn { conn := &webRTCConn{pc: pc, dc: dc, pr: pr, eventLogger: eventLogger} conn.bytesLogger = newBytesSyncLogger() conn.activity = make(chan struct{}, 100) + conn.closed = make(chan struct{}) conn.inactivityTimeout = 30 * time.Second go conn.timeoutLoop() return conn @@ -55,9 +57,10 @@ func (c *webRTCConn) timeoutLoop() { return case <-c.activity: continue + case <-c.closed: + return } } - }
func (c *webRTCConn) Read(b []byte) (int, error) { @@ -77,6 +80,7 @@ func (c *webRTCConn) Write(b []byte) (int, error) {
func (c *webRTCConn) Close() (err error) { c.once.Do(func() { + close(c.closed) err = c.pc.Close() }) return