From eda24ec871e29cdf0604155bc2cce6fb7b8db018 Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Tue, 7 Mar 2023 20:27:02 +0800 Subject: [PATCH] routing: catch lifecycle quit signal in `collectResult` --- routing/payment_lifecycle.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/routing/payment_lifecycle.go b/routing/payment_lifecycle.go index 511ef3596..d0f43d7b0 100644 --- a/routing/payment_lifecycle.go +++ b/routing/payment_lifecycle.go @@ -17,6 +17,10 @@ import ( "github.com/lightningnetwork/lnd/routing/shards" ) +// ErrPaymentLifecycleExiting is used when waiting for htlc attempt result, but +// the payment lifecycle is exiting . +var ErrPaymentLifecycleExiting = errors.New("payment lifecycle exiting") + // paymentLifecycle holds all information about the current state of a payment // needed to resume if from any point. type paymentLifecycle struct { @@ -496,6 +500,9 @@ func (p *paymentLifecycle) collectResult(attempt *channeldb.HTLCAttempt) ( return nil, htlcswitch.ErrSwitchExiting } + case <-p.quit: + return nil, ErrPaymentLifecycleExiting + case <-p.router.quit: return nil, ErrRouterShuttingDown }