rpcwallet: fix RPC wallet health check connection leak

Fixes #6329.
This commit fixes a connection leak in the RPC wallet's health check. By
not closing the test connection the watch-only node would slowly stack
up connections and eventually hit the ulimit.
This commit is contained in:
Oliver Gugger
2022-03-16 15:11:17 +01:00
parent 42b0aa9a8e
commit 8c44da225a

View File

@@ -11,7 +11,7 @@ import (
// configuration.
func HealthCheck(cfg *lncfg.RemoteSigner, timeout time.Duration) func() error {
return func() error {
_, err := connectRPC(
conn, err := connectRPC(
cfg.RPCHost, cfg.TLSCertPath, cfg.MacaroonPath, timeout,
)
if err != nil {
@@ -19,6 +19,15 @@ func HealthCheck(cfg *lncfg.RemoteSigner, timeout time.Duration) func() error {
"signing node through RPC: %v", err)
}
defer func() {
err = conn.Close()
if err != nil {
log.Warnf("Failed to close health check "+
"connection to remote signing node: %v",
err)
}
}()
return nil
}
}