Skip to content

Commit

Permalink
Close multiplexer when context is cancelled
Browse files Browse the repository at this point in the history
Multiplexer continues to create rpc connections even when
the context which is passed to the underlying rpc connections
is cancelled by the server.

This was causing #4413 - when a SIGHUP causes everything to reload,
it uses context to cancel the underlying http/rpc connections
so that they may come up with the new configuration.
The multiplexer was not being cancelled properly so it would
continue to create rpc connections and constantly fail,
causing communication issues with other nomad agents.

Fixes #4413
  • Loading branch information
Xopherus committed Aug 10, 2018
1 parent 827dbab commit aa25316
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 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

0 comments on commit aa25316

Please sign in to comment.