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.
This commit is contained in:
David Fifield 2020-04-23 21:01:19 -06:00
parent 51bb49fa6f
commit d9b076c32e

View file

@ -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.")