Fix dead lock at session mutex#1199
Open
riebl wants to merge 2 commits into
Open
Conversation
Signed-off-by: Raphael Riebl <raphael@riebl.net>
Signed-off-by: Raphael Riebl <raphael@riebl.net>
Contributor
|
It is generally not advised to do any blocking operation (which the publish is) from callbacks, since this starves zenoh-pico background thread - one can use channels if needed for this purpose. |
Author
|
Yes, I also merely schedule the publisher invocation in my callback now. However, it can be a quite unpleasant surprise when switching from zenoh-c to zenoh-pico as backend for zenoh-cpp and suddenly the application is trapped in a deadlock. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
With LOCAL_PUBLISHER and LOCAL_QUERYABLE enabled, I noticed a deadlock when publishing from a query callback (using zenoh-cpp with zenoh-pico backend).
What does this PR do?
Callbacks are no longer invoked while session mutex is still locked. Instead, the callback function pointer and its argument are stored on stack and invoked as soon as session mutex is unlocked.
Why is this change needed?
Publisher blocks infinitely at session mutex when called from a callback and session mutex is already acquired by call stack.
Related Issues
N/A
🏷️ Label-Based Checklist
No specific label requirements detected.
Current labels: No labels
Add one of these labels to this PR to see relevant checklist items:
api-sync,breaking-change,bug,ci,dependencies,documentation,enhancement,new feature,internalThis section updates automatically when labels change.