mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 09:53:54 +01:00
htlcswitch: ensure we don't attempt to create fwding events for fails
In this commit, we fix an existing source of a panic, that could at times lead to a deadlock. If the circuit returned from closeCircuit didn't have an outgoing key (as it was an incomplete forward), then we would attempt to de-ref a nil pointer. This would trigger a panic, and the runtime would start to unwind the stack, and execute each defer in line. A deadlock can arise here, as in the defer at the root goroutine, we need to grab the fwdingEventMtx. However, we already have it at the panic site. We fix this issue by ensuring we only attempt to add the event if it's a _settle_ and also actually has an outgoing circuit (which it should already, just a defensive check).
This commit is contained in:
parent
95293f5102
commit
5e3b239ebc
@ -1061,7 +1061,7 @@ func (s *Switch) handlePacketForward(packet *htlcPacket) error {
|
||||
fail.Reason,
|
||||
)
|
||||
}
|
||||
} else {
|
||||
} else if !isFail && circuit.Outgoing != nil {
|
||||
// If this is an HTLC settle, and it wasn't from a
|
||||
// locally initiated HTLC, then we'll log a forwarding
|
||||
// event so we can flush it to disk later.
|
||||
|
Loading…
Reference in New Issue
Block a user