mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 18:10:34 +01:00
8c44da225a
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.
34 lines
687 B
Go
34 lines
687 B
Go
package rpcwallet
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
|
|
"github.com/lightningnetwork/lnd/lncfg"
|
|
)
|
|
|
|
// HealthCheck returns a health check function for the given remote signing
|
|
// configuration.
|
|
func HealthCheck(cfg *lncfg.RemoteSigner, timeout time.Duration) func() error {
|
|
return func() error {
|
|
conn, err := connectRPC(
|
|
cfg.RPCHost, cfg.TLSCertPath, cfg.MacaroonPath, timeout,
|
|
)
|
|
if err != nil {
|
|
return fmt.Errorf("error connecting to the remote "+
|
|
"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
|
|
}
|
|
}
|