Skip to content

Commit

Permalink
fix goroutine leak when reloading server config (#469)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
aead authored Jun 17, 2024
1 parent f111da8 commit 12195cc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion keystore.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 12195cc

Please sign in to comment.