Skip to content

Commit

Permalink
opt: avoid the long hanging when the peer crashes
Browse files Browse the repository at this point in the history
Fixes #341
  • Loading branch information
panjf2000 committed Mar 12, 2022
1 parent da518d6 commit c138ac5
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 @@ -199,12 +199,12 @@ func (el *eventloop) closeConn(c *conn, err error) (rerr error) {
if len(iov) > iovMax {
iov = iov[:iovMax]
}
n, err := io.Writev(c.fd, iov)
if err != nil && err != unix.EAGAIN {
el.getLogger().Warnf("closeConn: error occurs when sending data back to peer, %v", err)
if n, e := io.Writev(c.fd, iov); e != nil {
el.getLogger().Warnf("closeConn: error occurs when sending data back to peer, %v", e)
break
} else {
_, _ = c.outboundBuffer.Discard(n)
}
_, _ = c.outboundBuffer.Discard(n)
}
}

Expand Down

0 comments on commit c138ac5

Please sign in to comment.