-
Notifications
You must be signed in to change notification settings - Fork 404
Fix persistence-required futures always completing instantly #1845
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix persistence-required futures always completing instantly #1845
Conversation
Codecov ReportBase: 90.74% // Head: 92.01% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #1845 +/- ##
==========================================
+ Coverage 90.74% 92.01% +1.27%
==========================================
Files 87 89 +2
Lines 47364 61307 +13943
Branches 47364 61307 +13943
==========================================
+ Hits 42980 56412 +13432
- Misses 4384 4895 +511
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
d7a1380
to
6aefbe5
Compare
Fixed the doc links, note that we can't actually link |
After the first persistence-required `Future` wakeup, we'll always complete additional futures instantly as we don't clear the "need wake" bit. Instead, we need to just assume that if a future was generated (and not immediately drop'd) that its sufficient to notify the user.
2004451
to
f382f56
Compare
Squashed, the fixup commit after @wpaulino's review was: $ git diff-tree -U1 57855ff9c0b62d4a05b77bb512a3694e2dcaec8b f382f56c
diff --git a/lightning/src/util/wakers.rs b/lightning/src/util/wakers.rs
index 92fdd0165..655fc9cf7 100644
--- a/lightning/src/util/wakers.rs
+++ b/lightning/src/util/wakers.rs
@@ -95,10 +95,12 @@ impl Notifier {
}
- if !future_probably_generated_calls {
- // If no future made any callbacks and has been drop'd (i.e. the state has only the one
- // reference we hold), assume the user was not notified and set the
- // notification-required flag. This will cause the `wait` functions above to return.
- lock.0 = true;
+ if future_probably_generated_calls {
+ // If a future made some callbacks or has not yet been drop'd (i.e. the state has more
+ // than the one reference we hold), assume the user was notified and skip setting the
+ // notification-required flag. This will not cause the `wait` functions above to return
+ // and avoid any future `Future`s starting in a completed state.
+ return;
}
+ lock.0 = true;
mem::drop(lock);
- if !future_probably_generated_calls { self.condvar.notify_all(); }
+ self.condvar.notify_all();
} |
After the first persistence-required
Future
wakeup, we'll always complete additional futures instantly as we don't clear the "need wake" bit. Instead, we need to just assume that if a future was generated (and not immediately drop'd) that its sufficient to notify the user.