diff --git a/connection_unix.go b/connection_unix.go index 18a33d2fe..b82bc9336 100644 --- a/connection_unix.go +++ b/connection_unix.go @@ -149,7 +149,7 @@ func (c *conn) write(data []byte) (n int, err error) { logging.Errorf("failed to close connection(fd=%d,peer=%+v) on conn.write: %v", c.fd, c.remoteAddr, err) } - return -1, os.NewSyscallError("write", err) + return 0, os.NewSyscallError("write", err) } // Failed to send all data back to the peer, buffer the leftover data for the next round. if sent < n { @@ -183,7 +183,7 @@ func (c *conn) writev(bs [][]byte) (n int, err error) { logging.Errorf("failed to close connection(fd=%d,peer=%+v) on conn.writev: %v", c.fd, c.remoteAddr, err) } - return -1, os.NewSyscallError("writev", err) + return 0, os.NewSyscallError("writev", err) } // Failed to send all data back to the peer, buffer the leftover data for the next round. if sent < n { diff --git a/eventloop_unix.go b/eventloop_unix.go index f3082f14f..e8c8eab92 100644 --- a/eventloop_unix.go +++ b/eventloop_unix.go @@ -100,7 +100,7 @@ func (el *eventloop) open(c *conn) error { } if !c.outboundBuffer.IsEmpty() { - if err := el.poller.AddWrite(&c.pollAttachment); err != nil { + if err := el.poller.ModReadWrite(&c.pollAttachment); err != nil { return err } }