From 523ecc0653f24598790a28510f52e64c78234db3 Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Sun, 3 Nov 2024 20:19:38 +0800 Subject: [PATCH] multi: wait for rpcclients shutdown to complete We need to call `WaitForShutdown` after stopping the rpc clients of the chain backends. --- chainntnfs/bitcoindnotify/bitcoind.go | 1 + chainntnfs/btcdnotify/btcd.go | 2 +- go.mod | 2 +- go.sum | 4 ++-- lnwallet/chainfee/estimator.go | 1 + routing/chainview/bitcoind.go | 1 + routing/chainview/btcd.go | 1 + 7 files changed, 8 insertions(+), 4 deletions(-) diff --git a/chainntnfs/bitcoindnotify/bitcoind.go b/chainntnfs/bitcoindnotify/bitcoind.go index f0547e4df..8bcf8872b 100644 --- a/chainntnfs/bitcoindnotify/bitcoind.go +++ b/chainntnfs/bitcoindnotify/bitcoind.go @@ -139,6 +139,7 @@ func (b *BitcoindNotifier) Stop() error { // Shutdown the rpc client, this gracefully disconnects from bitcoind, // and cleans up all related resources. b.chainConn.Stop() + b.chainConn.WaitForShutdown() close(b.quit) b.wg.Wait() diff --git a/chainntnfs/btcdnotify/btcd.go b/chainntnfs/btcdnotify/btcd.go index 1bf63f1e6..bcbfa571a 100644 --- a/chainntnfs/btcdnotify/btcd.go +++ b/chainntnfs/btcdnotify/btcd.go @@ -180,7 +180,7 @@ func (b *BtcdNotifier) Stop() error { // Shutdown the rpc client, this gracefully disconnects from btcd, and // cleans up all related resources. - b.chainConn.Shutdown() + b.chainConn.Stop() close(b.quit) b.wg.Wait() diff --git a/go.mod b/go.mod index e0bda2c29..586cc3299 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 github.com/btcsuite/btclog v0.0.0-20241003133417-09c4e92e319c github.com/btcsuite/btclog/v2 v2.0.0-20241017175713-3428138b75c7 - github.com/btcsuite/btcwallet v0.16.10-0.20240912233857-ffb143c77cc5 + github.com/btcsuite/btcwallet v0.16.10-0.20241113134707-b4ff60753aaa github.com/btcsuite/btcwallet/wallet/txauthor v1.3.5 github.com/btcsuite/btcwallet/wallet/txrules v1.2.2 github.com/btcsuite/btcwallet/walletdb v1.4.4 diff --git a/go.sum b/go.sum index 0cf08569c..b64a5c43d 100644 --- a/go.sum +++ b/go.sum @@ -95,8 +95,8 @@ github.com/btcsuite/btclog v0.0.0-20241003133417-09c4e92e319c/go.mod h1:w7xnGOhw github.com/btcsuite/btclog/v2 v2.0.0-20241017175713-3428138b75c7 h1:3Ct3zN3VCEKVm5nceWBBEKczc+jvTfVyOEG71ob2Yuc= github.com/btcsuite/btclog/v2 v2.0.0-20241017175713-3428138b75c7/go.mod h1:XItGUfVOxotJL8kkuk2Hj3EVow5KCugXl3wWfQ6K0AE= github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= -github.com/btcsuite/btcwallet v0.16.10-0.20240912233857-ffb143c77cc5 h1:zYy233eUBvkF3lq2MUkybEhxhDsrRDSgiToIKN57mtk= -github.com/btcsuite/btcwallet v0.16.10-0.20240912233857-ffb143c77cc5/go.mod h1:1HJXYbjJzgumlnxOC2+ViR1U+gnHWoOn7WeK5OfY1eU= +github.com/btcsuite/btcwallet v0.16.10-0.20241113134707-b4ff60753aaa h1:x7vYpwkPL5zeJEWPPaRunybH9ERRMGWeNf7x/0aU/38= +github.com/btcsuite/btcwallet v0.16.10-0.20241113134707-b4ff60753aaa/go.mod h1:1HJXYbjJzgumlnxOC2+ViR1U+gnHWoOn7WeK5OfY1eU= github.com/btcsuite/btcwallet/wallet/txauthor v1.3.5 h1:Rr0njWI3r341nhSPesKQ2JF+ugDSzdPoeckS75SeDZk= github.com/btcsuite/btcwallet/wallet/txauthor v1.3.5/go.mod h1:+tXJ3Ym0nlQc/iHSwW1qzjmPs3ev+UVWMbGgfV1OZqU= github.com/btcsuite/btcwallet/wallet/txrules v1.2.2 h1:YEO+Lx1ZJJAtdRrjuhXjWrYsmAk26wLTlNzxt2q0lhk= diff --git a/lnwallet/chainfee/estimator.go b/lnwallet/chainfee/estimator.go index 6f59c3f7f..f83cce285 100644 --- a/lnwallet/chainfee/estimator.go +++ b/lnwallet/chainfee/estimator.go @@ -238,6 +238,7 @@ func (b *BtcdEstimator) Stop() error { b.filterManager.Stop() b.btcdConn.Shutdown() + b.btcdConn.WaitForShutdown() return nil } diff --git a/routing/chainview/bitcoind.go b/routing/chainview/bitcoind.go index 56e30c24a..cbddb37c1 100644 --- a/routing/chainview/bitcoind.go +++ b/routing/chainview/bitcoind.go @@ -136,6 +136,7 @@ func (b *BitcoindFilteredChainView) Stop() error { // Shutdown the rpc client, this gracefully disconnects from bitcoind's // zmq socket, and cleans up all related resources. b.chainClient.Stop() + b.chainClient.WaitForShutdown() b.blockQueue.Stop() diff --git a/routing/chainview/btcd.go b/routing/chainview/btcd.go index 54c2ee4db..cf08abafe 100644 --- a/routing/chainview/btcd.go +++ b/routing/chainview/btcd.go @@ -146,6 +146,7 @@ func (b *BtcdFilteredChainView) Stop() error { // Shutdown the rpc client, this gracefully disconnects from btcd, and // cleans up all related resources. b.btcdConn.Shutdown() + b.btcdConn.WaitForShutdown() b.blockQueue.Stop()