Fixed hang on detach closed

This commit is contained in:
tidwall 2018-11-05 11:58:07 -07:00
parent 67a98f8d46
commit ea610eff86
1 changed files with 12 additions and 1 deletions

View File

@ -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) {