@@ -2720,6 +2720,10 @@ pub struct ChannelManager<
2720
2720
/// A simple atomic flag to ensure only one task at a time can be processing events asynchronously.
2721
2721
pending_events_processor: AtomicBool,
2722
2722
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
+
2723
2727
/// If we are running during init (either directly during the deserialization method or in
2724
2728
/// block connection methods which run after deserialization but before normal operation) we
2725
2729
/// cannot provide the user with [`ChannelMonitorUpdate`]s through the normal update flow -
@@ -3784,6 +3788,7 @@ where
3784
3788
3785
3789
pending_events: Mutex::new(VecDeque::new()),
3786
3790
pending_events_processor: AtomicBool::new(false),
3791
+ pending_htlc_forwards_processor: AtomicBool::new(false),
3787
3792
pending_background_events: Mutex::new(Vec::new()),
3788
3793
total_consistency_lock: RwLock::new(()),
3789
3794
background_events_processed_since_startup: AtomicBool::new(false),
@@ -6337,8 +6342,7 @@ where
6337
6342
///
6338
6343
/// Will regularly be called by the background processor.
6339
6344
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
6342
6346
.compare_exchange(false, true, Ordering::Acquire, Ordering::Relaxed)
6343
6347
.is_err()
6344
6348
{
@@ -7186,7 +7190,7 @@ where
7186
7190
}
7187
7191
should_persist
7188
7192
});
7189
- REENTRANCY_GUARD .store(false, Ordering::Release);
7193
+ self.pending_htlc_forwards_processor .store(false, Ordering::Release);
7190
7194
}
7191
7195
7192
7196
/// Free the background events, generally called from [`PersistenceNotifierGuard`] constructors.
@@ -16380,6 +16384,7 @@ where
16380
16384
16381
16385
pending_events: Mutex::new(pending_events_read),
16382
16386
pending_events_processor: AtomicBool::new(false),
16387
+ pending_htlc_forwards_processor: AtomicBool::new(false),
16383
16388
pending_background_events: Mutex::new(pending_background_events),
16384
16389
total_consistency_lock: RwLock::new(()),
16385
16390
background_events_processed_since_startup: AtomicBool::new(false),
0 commit comments