routing: catch lifecycle quit signal in collectResult

This commit is contained in:
yyforyongyu committed 2023-11-13 16:09:11 +08:00
1 parent da8f1c084a
commit eda24ec871
1 file changed
+7
+7
View File
@@ -17,6 +17,10 @@ import (
"github.com/lightningnetwork/lnd/routing/shards" "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 // paymentLifecycle holds all information about the current state of a payment
// needed to resume if from any point. // needed to resume if from any point.
type paymentLifecycle struct { type paymentLifecycle struct {
@@ -496,6 +500,9 @@ func (p *paymentLifecycle) collectResult(attempt *channeldb.HTLCAttempt) (
return nil, htlcswitch.ErrSwitchExiting return nil, htlcswitch.ErrSwitchExiting
} }
case <-p.quit:
return nil, ErrPaymentLifecycleExiting
case <-p.router.quit: case <-p.router.quit:
return nil, ErrRouterShuttingDown return nil, ErrRouterShuttingDown
} }