mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-28 18:06:31 +02:00
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:
@@ -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
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user