Skip to content

Commit

Permalink
Fixed hang on detach closed
Browse files Browse the repository at this point in the history
  • Loading branch information
tidwall committed Nov 5, 2018
1 parent 67a98f8 commit ea610ef
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion evio_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package evio

import (
"io"
"net"
"os"
"runtime"
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit ea610ef

Please sign in to comment.