From 12195cc387d860517221548b6297471c92978f68 Mon Sep 17 00:00:00 2001 From: Andreas Auernhammer Date: Mon, 17 Jun 2024 17:47:05 +0200 Subject: [PATCH] fix goroutine leak when reloading server config (#469) This commit fixes a goroutine leak that occurs when reloading the server configuration. During a config reload, the server establishes a 2nd connection to the backend keystore and replaces the existing connection with the newly opened one. The switch is performed atomically (without locking) to not block or abort ongoing requests. Once the server has replaced the keystore connection, it closes it. Before this commit, the server stopped the in-memory key cache and its GC goroutines. However, it did not close any resources (goroutines/file descriptors) allocated by the replaced keystore. This commit fixes this. Signed-off-by: Andreas Auernhammer --- keystore.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keystore.go b/keystore.go index 6dd0aa6d..d944bce2 100644 --- a/keystore.go +++ b/keystore.go @@ -348,7 +348,7 @@ func (c *keyCache) List(ctx context.Context, prefix string, n int) ([]string, st // releases associated resources. func (c *keyCache) Close() error { c.stop() - return nil + return c.store.Close() } // gc executes f periodically until the ctx.Done() channel returns.