mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-14 05:11:19 -04:00
pull copyLoop out of goroutine, better pop and reset
This commit is contained in:
parent
a71c98c0ae
commit
2bf0e5457e
5 changed files with 70 additions and 35 deletions
|
@ -31,7 +31,7 @@ type webRTCConn struct {
|
|||
BytesLogger
|
||||
}
|
||||
|
||||
// Read bytes from remote WebRTC.
|
||||
// Read bytes from local SOCKS.
|
||||
// As part of |io.ReadWriter|
|
||||
func (c *webRTCConn) Read(b []byte) (int, error) {
|
||||
return c.recvPipe.Read(b)
|
||||
|
@ -62,11 +62,11 @@ func (c *webRTCConn) Close() error {
|
|||
|
||||
// As part of |Resetter|
|
||||
func (c *webRTCConn) Reset() {
|
||||
c.Close()
|
||||
go func() {
|
||||
c.reset <- struct{}{}
|
||||
log.Println("WebRTC resetting...")
|
||||
}()
|
||||
c.Close()
|
||||
}
|
||||
|
||||
// As part of |Resetter|
|
||||
|
@ -282,6 +282,11 @@ func (c *webRTCConn) cleanup() {
|
|||
if nil != c.errorChannel {
|
||||
close(c.errorChannel)
|
||||
}
|
||||
// Close this side of the SOCKS pipe.
|
||||
if nil != c.writePipe {
|
||||
c.writePipe.Close()
|
||||
c.writePipe = nil
|
||||
}
|
||||
if nil != c.transport {
|
||||
log.Printf("WebRTC: closing DataChannel")
|
||||
dataChannel := c.transport
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue