Skip to content

Commit

Permalink
chore: refine eventloop.read(*conn)
Browse files Browse the repository at this point in the history
  • Loading branch information
panjf2000 committed Mar 13, 2022
1 parent b1eb3e8 commit 86b3499
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions eventloop.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,15 @@ func (el *eventloop) open(c *conn) error {

func (el *eventloop) read(c *conn) error {
n, err := unix.Read(c.fd, el.buffer)
if err != nil {
if err != nil || n == 0 {
if err == unix.EAGAIN {
return nil
}
if n == 0 {
err = unix.ECONNRESET
}
return el.closeConn(c, os.NewSyscallError("read", err))
}
if n == 0 {
return el.closeConn(c, os.NewSyscallError("read", unix.ECONNRESET))
}

c.buffer = el.buffer[:n]
action := el.eventHandler.OnTraffic(c)
Expand Down

0 comments on commit 86b3499

Please sign in to comment.