From b3ded75ababcc37059501f2445b3dc76f7d0cde4 Mon Sep 17 00:00:00 2001 From: Fisher <44502786+daynobug@users.noreply.github.com> Date: Fri, 5 Apr 2024 19:06:10 +0800 Subject: [PATCH] bug: return 0 instead of -1 when error occurred on a write (#569) --- connection_unix.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 {