From d7655a9db0d083ca5d7db56cdbbbef0716e1a91b Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Mon, 15 Oct 2018 11:02:53 -0400 Subject: [PATCH] Buffer authhandler output channel to prevent hang on shutdown (#5507) Fixes #5026 --- command/agent/auth/auth.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/command/agent/auth/auth.go b/command/agent/auth/auth.go index 6a9127f9b4..f3733a4ecc 100644 --- a/command/agent/auth/auth.go +++ b/command/agent/auth/auth.go @@ -43,8 +43,10 @@ type AuthHandlerConfig struct { func NewAuthHandler(conf *AuthHandlerConfig) *AuthHandler { ah := &AuthHandler{ - DoneCh: make(chan struct{}), - OutputCh: make(chan string), + DoneCh: make(chan struct{}), + // This is buffered so that if we try to output after the sink server + // has been shut down, during agent shutdown, we won't block + OutputCh: make(chan string, 1), logger: conf.Logger, client: conf.Client, random: rand.New(rand.NewSource(int64(time.Now().Nanosecond()))),