Skip to content

Commit c759999

Browse files
committed
f - fix lock order bug
1 parent 664696c commit c759999

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13576,7 +13576,7 @@ where
1357613576
#[rustfmt::skip]
1357713577
fn peer_disconnected(&self, counterparty_node_id: PublicKey) {
1357813578
let _persistence_guard = PersistenceNotifierGuard::optionally_notify(self, || {
13579-
let mut persist = NotifyOption::SkipPersistHandleEvents;
13579+
let mut splice_failed_events = Vec::new();
1358013580
let mut failed_channels: Vec<(Result<Infallible, _>, _)> = Vec::new();
1358113581
let mut per_peer_state = self.per_peer_state.write().unwrap();
1358213582
let remove_peer = {
@@ -13589,23 +13589,21 @@ where
1358913589
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
1359013590
let peer_state = &mut *peer_state_lock;
1359113591
let pending_msg_events = &mut peer_state.pending_msg_events;
13592-
let pending_events = &mut self.pending_events.lock().unwrap();
1359313592
peer_state.channel_by_id.retain(|_, chan| {
1359413593
let logger = WithChannelContext::from(&self.logger, &chan.context(), None);
1359513594
let DisconnectResult { is_resumable, splice_funding_failed } =
1359613595
chan.peer_disconnected_is_resumable(&&logger);
1359713596

1359813597
if let Some(splice_funding_failed) = splice_funding_failed {
13599-
pending_events.push_back((events::Event::SpliceFailed {
13598+
splice_failed_events.push(events::Event::SpliceFailed {
1360013599
channel_id: chan.context().channel_id(),
1360113600
counterparty_node_id,
1360213601
user_channel_id: chan.context().get_user_id(),
1360313602
abandoned_funding_txo: splice_funding_failed.funding_txo,
1360413603
channel_type: splice_funding_failed.channel_type,
1360513604
contributed_inputs: splice_funding_failed.contributed_inputs,
1360613605
contributed_outputs: splice_funding_failed.contributed_outputs,
13607-
}, None));
13608-
persist = NotifyOption::DoPersist;
13606+
});
1360913607
}
1361013608

1361113609
if is_resumable {
@@ -13691,6 +13689,18 @@ where
1369113689
}
1369213690
mem::drop(per_peer_state);
1369313691

13692+
let persist = if splice_failed_events.is_empty() {
13693+
NotifyOption::SkipPersistHandleEvents
13694+
} else {
13695+
NotifyOption::DoPersist
13696+
};
13697+
13698+
let mut pending_events = self.pending_events.lock().unwrap();
13699+
for event in splice_failed_events {
13700+
pending_events.push_back((event, None));
13701+
}
13702+
mem::drop(pending_events);
13703+
1369413704
for (err, counterparty_node_id) in failed_channels.drain(..) {
1369513705
let _ = handle_error!(self, err, counterparty_node_id);
1369613706
}

0 commit comments

Comments
 (0)