Skip to content

Commit a8c1d66

Browse files
committed
f Switch to non-static variable for consistency
1 parent 8a67f2a commit a8c1d66

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2720,6 +2720,10 @@ pub struct ChannelManager<
27202720
/// A simple atomic flag to ensure only one task at a time can be processing events asynchronously.
27212721
pending_events_processor: AtomicBool,
27222722

2723+
/// A simple atomic flag to ensure only one task at a time can be processing HTLC forwards via
2724+
/// [`Self::process_pending_htlc_forwards`].
2725+
pending_htlc_forwards_processor: AtomicBool,
2726+
27232727
/// If we are running during init (either directly during the deserialization method or in
27242728
/// block connection methods which run after deserialization but before normal operation) we
27252729
/// cannot provide the user with [`ChannelMonitorUpdate`]s through the normal update flow -
@@ -3784,6 +3788,7 @@ where
37843788

37853789
pending_events: Mutex::new(VecDeque::new()),
37863790
pending_events_processor: AtomicBool::new(false),
3791+
pending_htlc_forwards_processor: AtomicBool::new(false),
37873792
pending_background_events: Mutex::new(Vec::new()),
37883793
total_consistency_lock: RwLock::new(()),
37893794
background_events_processed_since_startup: AtomicBool::new(false),
@@ -6337,8 +6342,7 @@ where
63376342
///
63386343
/// Will regularly be called by the background processor.
63396344
pub fn process_pending_htlc_forwards(&self) {
6340-
static REENTRANCY_GUARD: AtomicBool = AtomicBool::new(false);
6341-
if REENTRANCY_GUARD
6345+
if self.pending_htlc_forwards_processor
63426346
.compare_exchange(false, true, Ordering::Acquire, Ordering::Relaxed)
63436347
.is_err()
63446348
{
@@ -7186,7 +7190,7 @@ where
71867190
}
71877191
should_persist
71887192
});
7189-
REENTRANCY_GUARD.store(false, Ordering::Release);
7193+
self.pending_htlc_forwards_processor.store(false, Ordering::Release);
71907194
}
71917195

71927196
/// Free the background events, generally called from [`PersistenceNotifierGuard`] constructors.
@@ -16380,6 +16384,7 @@ where
1638016384

1638116385
pending_events: Mutex::new(pending_events_read),
1638216386
pending_events_processor: AtomicBool::new(false),
16387+
pending_htlc_forwards_processor: AtomicBool::new(false),
1638316388
pending_background_events: Mutex::new(pending_background_events),
1638416389
total_consistency_lock: RwLock::new(()),
1638516390
background_events_processed_since_startup: AtomicBool::new(false),

0 commit comments

Comments
 (0)