Merge pull request #4573 from Xopherus/fix-4413

Close multiplexer when context is cancelled
This commit is contained in:
Chelsea Komlo 2018-08-14 13:18:31 -04:00 committed by GitHub
commit f011649ac5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -208,6 +208,11 @@ func (s *Server) handleMultiplex(ctx context.Context, conn net.Conn, rpcCtx *RPC
s.setupRpcServer(rpcServer, rpcCtx) s.setupRpcServer(rpcServer, rpcCtx)
for { for {
// stop handling connections if context was cancelled
if ctx.Err() != nil {
return
}
sub, err := server.Accept() sub, err := server.Accept()
if err != nil { if err != nil {
if err != io.EOF { if err != io.EOF {
@ -311,6 +316,11 @@ func (s *Server) handleMultiplexV2(ctx context.Context, conn net.Conn, rpcCtx *R
s.setupRpcServer(rpcServer, rpcCtx) s.setupRpcServer(rpcServer, rpcCtx)
for { for {
// stop handling connections if context was cancelled
if ctx.Err() != nil {
return
}
// Accept a new stream // Accept a new stream
sub, err := server.Accept() sub, err := server.Accept()
if err != nil { if err != nil {