From ea610eff86981249be649bbdcedbf409a2db2173 Mon Sep 17 00:00:00 2001 From: tidwall Date: Mon, 5 Nov 2018 11:58:07 -0700 Subject: [PATCH] Fixed hang on detach closed --- evio_unix.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/evio_unix.go b/evio_unix.go index f05e3ec..16c696e 100644 --- a/evio_unix.go +++ b/evio_unix.go @@ -7,6 +7,7 @@ package evio import ( + "io" "net" "os" "runtime" @@ -458,7 +459,17 @@ func (c *detachedConn) Close() error { } func (c *detachedConn) Read(p []byte) (n int, err error) { - return syscall.Read(c.fd, p) + n, err = syscall.Read(c.fd, p) + if err != nil { + return n, err + } + if n == 0 { + if len(p) == 0 { + return 0, nil + } + return 0, io.EOF + } + return n, nil } func (c *detachedConn) Write(p []byte) (n int, err error) {