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 1/2] 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 { From 601bfdf18428aa05845ab5008b30f1c4f62184ae Mon Sep 17 00:00:00 2001 From: Andy Pan Date: Sun, 14 Apr 2024 10:12:11 +0800 Subject: [PATCH 2/2] bug: fix the EEXIST of epoll_ctl in eventloop.open (#572) --- eventloop_unix.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 } }