mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 01:43:16 +01:00
breacharbiter: avoid infinite loop in exactRetribution
After a shutdown has been initiated, both registrations for spend ntfns and publishing txns can fail. The current behavior in the face of such failures is to continue trying, which is fine if we are online. However, this causes an infinite loop during shutdown, and lnd cannot exit since the routine is tracked by the brar's waitgroup. A simple fix is to select on the brar's quit channel after detecting a failure from either, allowing the breach arbiter to break out of this death cycle.
This commit is contained in:
parent
7bbcbc6fea
commit
3021a246f1
@ -519,7 +519,16 @@ secondLevelCheck:
|
||||
brarLog.Errorf("unable to check for spentness "+
|
||||
"of out_point=%v: %v",
|
||||
breachedOutput.outpoint, err)
|
||||
continue
|
||||
|
||||
// Registration may have failed if we've been
|
||||
// instructed to shutdown. If so, return here to
|
||||
// avoid entering an infinite loop.
|
||||
select {
|
||||
case <-b.quit:
|
||||
return
|
||||
default:
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
select {
|
||||
@ -575,7 +584,15 @@ secondLevelCheck:
|
||||
brarLog.Infof("Attempting to transfer HTLC revocations " +
|
||||
"to the second level")
|
||||
finalTx = nil
|
||||
goto secondLevelCheck
|
||||
|
||||
// Txn publication may fail if we're shutting down.
|
||||
// If so, return to avoid entering an infinite loop.
|
||||
select {
|
||||
case <-b.quit:
|
||||
return
|
||||
default:
|
||||
goto secondLevelCheck
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user