Skip to content

Commit

Permalink
Merge pull request #4573 from Xopherus/fix-4413
Browse files Browse the repository at this point in the history
Close multiplexer when context is cancelled
  • Loading branch information
chelseakomlo committed Aug 14, 2018
2 parents dafe580 + 3f24197 commit a24dd6d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions nomad/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,11 @@ func (s *Server) handleMultiplex(ctx context.Context, conn net.Conn, rpcCtx *RPC
s.setupRpcServer(rpcServer, rpcCtx)

for {
// stop handling connections if context was cancelled
if ctx.Err() != nil {
return
}

sub, err := server.Accept()
if err != nil {
if err != io.EOF {
Expand Down Expand Up @@ -311,6 +316,11 @@ func (s *Server) handleMultiplexV2(ctx context.Context, conn net.Conn, rpcCtx *R
s.setupRpcServer(rpcServer, rpcCtx)

for {
// stop handling connections if context was cancelled
if ctx.Err() != nil {
return
}

// Accept a new stream
sub, err := server.Accept()
if err != nil {
Expand Down

0 comments on commit a24dd6d

Please sign in to comment.