Skip to content

Commit

Permalink
issue 110: fix concurrent loopCloseConn causes panic (#111)
Browse files Browse the repository at this point in the history
Co-authored-by: robin <zhangrbing@126.com>
Fixes #110
  • Loading branch information
hihaha committed Jul 9, 2020
1 parent 38c6a25 commit 329ed32
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions eventloop_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,15 @@ func (el *eventloop) loopWrite(c *conn) error {
}

func (el *eventloop) loopCloseConn(c *conn, err error) error {
if !c.outboundBuffer.IsEmpty() && err == nil {
_ = el.loopWrite(c)
}

if !c.opened {
el.svr.logger.Debugf("The fd=%d in event-loop(%d) is already closed, skipping it", c.fd, el.idx)
return nil
}

if !c.outboundBuffer.IsEmpty() && err == nil {
_ = el.loopWrite(c)
}

err0, err1 := el.poller.Delete(c.fd), unix.Close(c.fd)
if err0 == nil && err1 == nil {
delete(el.connections, c.fd)
Expand Down

0 comments on commit 329ed32

Please sign in to comment.