Wake up wait set when adding a new waitable #505
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes a subtle bug that could cause subscriptions, clients, and services to stall out where new messages fail to wake up the wait set because the subscription, client, or service itself has not been added to the wait set yet.
The fix itself is very simple:
This was an oversight that was missed in the original PR that introduced async execution. The result was:
And so the fix is simply to explicitly trigger the wait set to wake up whenever we add a new waitable to it.
I've also added a test that will fail (at least most of the time, it's a bit of a race condition) if it gets ported to
main
and run without the fix toadd_to_wait_set
.As a bonus, I've added a
Publisher::notify_on_subscriber_ready
method since it was needed for the new test. Almost all of the changed lines of code are actually related to the new test.