Skip to content

Commit 1891450

Browse files
f - Only hold id_to_peer lock temporarily on removal
1 parent 40b7986 commit 1891450

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,8 +1261,10 @@ macro_rules! handle_error {
12611261

12621262
macro_rules! update_maps_on_chan_removal {
12631263
($self: expr, $channel: expr) => {
1264-
// The lockorder for id_to_peer is prior to short_to_chan_info.
1265-
let mut id_to_peer = $self.id_to_peer.lock().unwrap();
1264+
{
1265+
let mut id_to_peer = $self.id_to_peer.lock().unwrap();
1266+
id_to_peer.remove(&$channel.channel_id());
1267+
}
12661268
let mut short_to_chan_info = $self.short_to_chan_info.write().unwrap();
12671269
if let Some(short_id) = $channel.get_short_channel_id() {
12681270
short_to_chan_info.remove(&short_id);
@@ -1276,7 +1278,6 @@ macro_rules! update_maps_on_chan_removal {
12761278
let alias_removed = $self.outbound_scid_aliases.lock().unwrap().remove(&$channel.outbound_scid_alias());
12771279
debug_assert!(alias_removed);
12781280
}
1279-
id_to_peer.remove(&$channel.channel_id());
12801281
short_to_chan_info.remove(&$channel.outbound_scid_alias());
12811282
}
12821283
}

0 commit comments

Comments
 (0)