commit d9b076c32eed106a382a19bda973a9616cc44501 Author: David Fifield david@bamsoftware.com Date: Thu Apr 23 21:01:19 2020 -0600
Don't do a separate check for a short write.
A short write will result in a non-nil error. It's an io.PipeWriter anyway, which blocks until all the data has been read or the read end is closed, in which case it returns io.ErrClosedPipe if not some other error. --- client/lib/webrtc.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/client/lib/webrtc.go b/client/lib/webrtc.go index 3fe8410..389e02b 100644 --- a/client/lib/webrtc.go +++ b/client/lib/webrtc.go @@ -239,8 +239,8 @@ func (c *WebRTCPeer) establishDataChannel() error { if len(msg.Data) <= 0 { log.Println("0 length message---") } - c.BytesLogger.AddInbound(len(msg.Data)) n, err := c.writePipe.Write(msg.Data) + c.BytesLogger.AddInbound(n) if err != nil { // TODO: Maybe shouldn't actually close. log.Println("Error writing to SOCKS pipe") @@ -248,10 +248,6 @@ func (c *WebRTCPeer) establishDataChannel() error { log.Printf("c.writePipe.CloseWithError returned error: %v", inerr) } } - if n != len(msg.Data) { - log.Println("Error: short write") - panic("short write") - } c.lastReceive = time.Now() }) log.Println("WebRTC: DataChannel created.")
tor-commits@lists.torproject.org