mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-10-10 12:02:56 +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.
|
// configuration.
|
||||||
func HealthCheck(cfg *lncfg.RemoteSigner, timeout time.Duration) func() error {
|
func HealthCheck(cfg *lncfg.RemoteSigner, timeout time.Duration) func() error {
|
||||||
return func() error {
|
return func() error {
|
||||||
_, err := connectRPC(
|
conn, err := connectRPC(
|
||||||
cfg.RPCHost, cfg.TLSCertPath, cfg.MacaroonPath, timeout,
|
cfg.RPCHost, cfg.TLSCertPath, cfg.MacaroonPath, timeout,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -19,6 +19,15 @@ func HealthCheck(cfg *lncfg.RemoteSigner, timeout time.Duration) func() error {
|
|||||||
"signing node through RPC: %v", err)
|
"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
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user