diff --git a/lightning-background-processor/src/lib.rs b/lightning-background-processor/src/lib.rs index 38fde6842d3..ae5acd86541 100644 --- a/lightning-background-processor/src/lib.rs +++ b/lightning-background-processor/src/lib.rs @@ -976,11 +976,19 @@ impl BackgroundProcessor { scorer, stop_thread.load(Ordering::Acquire), { - Sleeper::from_two_futures( - &channel_manager.get_cm().get_event_or_persistence_needed_future(), - &chain_monitor.get_update_future(), - ) - .wait_timeout(Duration::from_millis(100)); + let sleeper = if let Some(om) = onion_messenger.as_ref() { + Sleeper::from_three_futures( + &channel_manager.get_cm().get_event_or_persistence_needed_future(), + &chain_monitor.get_update_future(), + &om.get_om().get_update_future(), + ) + } else { + Sleeper::from_two_futures( + &channel_manager.get_cm().get_event_or_persistence_needed_future(), + &chain_monitor.get_update_future(), + ) + }; + sleeper.wait_timeout(Duration::from_millis(100)); }, |_| Instant::now(), |time: &Instant, dur| time.elapsed().as_secs() > dur, diff --git a/lightning/src/util/wakers.rs b/lightning/src/util/wakers.rs index c95b3dbef3d..bccb62a2357 100644 --- a/lightning/src/util/wakers.rs +++ b/lightning/src/util/wakers.rs @@ -244,10 +244,20 @@ impl Sleeper { Self { notifiers: vec![Arc::clone(&future.state)] } } /// Constructs a new sleeper from two futures, allowing blocking on both at once. - // Note that this is the common case - a ChannelManager and ChainMonitor. pub fn from_two_futures(fut_a: &Future, fut_b: &Future) -> Self { Self { notifiers: vec![Arc::clone(&fut_a.state), Arc::clone(&fut_b.state)] } } + /// Constructs a new sleeper from three futures, allowing blocking on both at once. + // Note that this is the common case - a ChannelManager, a ChainMonitor, and an + // OnionMessenger. + pub fn from_three_futures(fut_a: &Future, fut_b: &Future, fut_c: &Future) -> Self { + let notifiers = vec![ + Arc::clone(&fut_a.state), + Arc::clone(&fut_b.state), + Arc::clone(&fut_c.state) + ]; + Self { notifiers } + } /// Constructs a new sleeper on many futures, allowing blocking on all at once. pub fn new(futures: Vec) -> Self { Self { notifiers: futures.into_iter().map(|f| Arc::clone(&f.state)).collect() }