Skip to content

Commit e2a0fc8

Browse files
f - Retrieve ids from short_to_chan_info before channel_state lock
1 parent f89e28f commit e2a0fc8

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2259,8 +2259,8 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
22592259
// short_channel_id is non-0 in any ::Forward.
22602260
if let &PendingHTLCRouting::Forward { ref short_channel_id, .. } = routing {
22612261
if let Some((err, code, chan_update)) = loop {
2262-
let mut channel_state = self.channel_state.lock().unwrap();
22632262
let id_option = self.short_to_chan_info.read().unwrap().get(&short_channel_id).cloned();
2263+
let mut channel_state = self.channel_state.lock().unwrap();
22642264
let forwarding_id_opt = match id_option {
22652265
None => { // unknown_next_peer
22662266
// Note that this is likely a timing oracle for detecting whether an scid is a
@@ -2447,13 +2447,12 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
24472447
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(&self.total_consistency_lock, &self.persistence_notifier);
24482448

24492449
let err: Result<(), _> = loop {
2450-
let mut channel_lock = self.channel_state.lock().unwrap();
2451-
24522450
let id = match self.short_to_chan_info.read().unwrap().get(&path.first().unwrap().short_channel_id) {
24532451
None => return Err(APIError::ChannelUnavailable{err: "No channel available with first hop!".to_owned()}),
24542452
Some((_cp_id, chan_id)) => chan_id.clone(),
24552453
};
24562454

2455+
let mut channel_lock = self.channel_state.lock().unwrap();
24572456
let mut pending_outbounds = self.pending_outbound_payments.lock().unwrap();
24582457
let payment_entry = pending_outbounds.entry(payment_id);
24592458
if let hash_map::Entry::Occupied(payment) = &payment_entry {

0 commit comments

Comments
 (0)