From b06ba3fe78a67c4425abf5b895fc947c994c8ed4 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Wed, 1 Apr 2026 21:28:03 +0000 Subject: [PATCH] Document that `Future` callbacks are not reentrant-safe Claude was complaining about this, and it seems worth documenting, but not worth (and kinda hard to) fix. --- lightning/src/util/wakers.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lightning/src/util/wakers.rs b/lightning/src/util/wakers.rs index 17edadfd822..1a0f08b5e66 100644 --- a/lightning/src/util/wakers.rs +++ b/lightning/src/util/wakers.rs @@ -165,6 +165,8 @@ impl Future { /// Registers a callback to be called upon completion of this future. If the future has already /// completed, the callback will be called immediately. /// + /// Note that callbacks *must not* reenter this [`Future`] or the corresponding [`Notifier`]. + /// /// This is not exported to bindings users, use the bindings-only `register_callback_fn` instead pub fn register_callback(&self, callback: Box) { let mut state = self.state.lock().unwrap(); @@ -182,6 +184,8 @@ impl Future { // here. /// Registers a callback to be called upon completion of this future. If the future has already /// completed, the callback will be called immediately. + /// + /// Note that callbacks *must not* reenter this [`Future`] or the corresponding [`Notifier`]. #[cfg(c_bindings)] pub fn register_callback_fn(&self, callback: F) { self.register_callback(Box::new(callback));