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:
13
cmux_test.go
13
cmux_test.go
@@ -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{})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user