From 263d35854b7a9ef23ab32235ce327d7c424915ba Mon Sep 17 00:00:00 2001 From: Nick Cabatoff Date: Wed, 19 Jan 2022 10:51:40 -0500 Subject: [PATCH] Don't say we've shut down cluster listener before having done so (#13679) --- changelog/13679.txt | 3 +++ vault/cluster/cluster.go | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 changelog/13679.txt diff --git a/changelog/13679.txt b/changelog/13679.txt new file mode 100644 index 00000000000000..c907ee7422309f --- /dev/null +++ b/changelog/13679.txt @@ -0,0 +1,3 @@ +```release-note:bug +core: Fix how we report the cluster listener is done, prevents `bind: address already in use` errors. +``` \ No newline at end of file diff --git a/vault/cluster/cluster.go b/vault/cluster/cluster.go index f5d25d73bd8023..b818a7ac256c5c 100644 --- a/vault/cluster/cluster.go +++ b/vault/cluster/cluster.go @@ -6,8 +6,6 @@ import ( "crypto/x509" "errors" "fmt" - "github.com/hashicorp/vault/sdk/helper/certutil" - "github.com/hashicorp/vault/sdk/helper/tlsutil" "net" "net/url" "os" @@ -16,7 +14,9 @@ import ( "time" log "github.com/hashicorp/go-hclog" + "github.com/hashicorp/vault/sdk/helper/certutil" "github.com/hashicorp/vault/sdk/helper/consts" + "github.com/hashicorp/vault/sdk/helper/tlsutil" "golang.org/x/net/http2" ) @@ -279,9 +279,9 @@ func (cl *Listener) Run(ctx context.Context) error { // Start our listening loop go func(closeCh chan struct{}, tlsLn net.Listener) { defer func() { - cl.shutdownWg.Done() tlsLn.Close() close(closeCh) + cl.shutdownWg.Done() }() // baseDelay is the initial delay after an Accept() error before attempting again