Skip to content

Commit 6cbfecb

Browse files
committed
Release short_to_chan_info lock throughout forwarding_channel_not_found
Not doing so caused a lock order inversion between the locks `ChannelManager::best_block` and `ChannelManager::short_to_chan_info` after the addition of `test_trigger_lnd_force_close`. It turns out that we were holding the `short_to_chan_info` for longer than needed when processing HTLC forwards. We only need to acquire it to quickly obtain channel info, and there aren't any other locks within `forwarding_channel_not_found` that depend on it being held.
1 parent 1f0928f commit 6cbfecb

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lightning/src/ln/channelmanager.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -4294,8 +4294,9 @@ where
42944294
}
42954295
}
42964296
}
4297-
let (counterparty_node_id, forward_chan_id) = match self.short_to_chan_info.read().unwrap().get(&short_chan_id) {
4298-
Some((cp_id, chan_id)) => (cp_id.clone(), chan_id.clone()),
4297+
let chan_info_opt = self.short_to_chan_info.read().unwrap().get(&short_chan_id).cloned();
4298+
let (counterparty_node_id, forward_chan_id) = match chan_info_opt {
4299+
Some((cp_id, chan_id)) => (cp_id, chan_id),
42994300
None => {
43004301
forwarding_channel_not_found!();
43014302
continue;

0 commit comments

Comments
 (0)