conn: fix goroutine leak
As is, soju leaks goroutines on client disconnects, because the closure started as goroutine in newConn never finishes. It gets stuck in the for loop annotated as "draining the outgoing channel", because the outgoing channel is in fact never closed. This commit fixes the issue by calling conn.Close rather than conn.conn.Close, which closes not only the underlying net.Conn (in c.conn), but also the channel.
This commit is contained in:
parent
3667102e72
commit
07502541e4
2
conn.go
2
conn.go
|
@ -157,7 +157,7 @@ func newConn(srv *Server, ic ircConn, options *connOptions) *conn {
|
|||
break
|
||||
}
|
||||
}
|
||||
if err := c.conn.Close(); err != nil && !errors.Is(err, net.ErrClosed) {
|
||||
if err := c.Close(); err != nil && !errors.Is(err, net.ErrClosed) {
|
||||
c.logger.Printf("failed to close connection: %v", err)
|
||||
} else {
|
||||
c.logger.Debugf("connection closed")
|
||||
|
|
Loading…
Reference in a new issue