2
0
mirror of https://github.com/soheilhy/cmux.git synced 2026-08-04 08:35:23 +08:00

Fix send on closed channel

If a matcher go-routine mateches a connection after the root
listener was closed, cmux will panic since all connection channels
will be closed. This commit avoids closing connection channels but
signals the matcher go-routines that the listener is closed via
a done channel.

Tested: Added a test case for this issue.
This commit is contained in:
Soheil Hassas Yeganeh
2015-08-30 21:07:48 -04:00
parent d47edebeb9
commit b90740dfa9
2 changed files with 26 additions and 7 deletions

View File

@@ -168,3 +168,16 @@ func TestErrorHandler(t *testing.T) {
t.Error("rpc got a response")
}
}
type closerConn struct {
net.Conn
}
func (c closerConn) Close() error { return nil }
func TestClosed(t *testing.T) {
mux := &cMux{}
lis := mux.Match(Any()).(muxListener)
close(lis.donec)
mux.serve(closerConn{})
}