-
Notifications
You must be signed in to change notification settings - Fork 791
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
Lock ordering issue in video conference bridge #3183
Merged
Merged
Conversation
This file contains 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
…ecking for source ports.
…nor updates, e.g: docs, clock tick holds lock only when there is any queued op.
sauwming
reviewed
Jul 14, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, can you merge with the latest master so I can do some local testing?
…ecking for source ports.
…nor updates, e.g: docs, clock tick holds lock only when there is any queued op.
…nto glock-for-port
Done, hopefully I didn't do it wrong, the traces above look a bit strange :) |
sauwming
reviewed
Jul 14, 2022
sauwming
approved these changes
Jul 15, 2022
bennylp
approved these changes
Jul 18, 2022
wosrediinanatour
pushed a commit
to wosrediinanatour/pjproject
that referenced
this pull request
Jan 16, 2023
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.
Sample scenario
put/get_frame()
publishes media event (synchronously), currentlyput/get_frame()
is called while holding the VC mutex and app receiving the event invokes a SIP dialog API which tries to acquire the SIP dialog mutex.The scenario involves non-uniform lock ordering between VC and SIP dialog mutexes which can cause deadlock.
Proposed solution
The proposed solution is to avoid holding VC mutex while calling
put/get_frame()
in VC worker thread. To allow this, a couple major modifications are implemented in this PR:put/get_frame()
is called, so some VC API operations (such as connect/disconnect ports, remove port, update port) must be queued or done asynchronously, the real operation will be performed in the VC worker thread context.Other fixes
This PR also contains a few minor other fixes such as:
pj_grp_lock_create_w_handler()
: memory pool used for adding handler, updated to using group lock's memory pool itself, previously using app pool, was getting a premature destroy issue because of this (i.e: VC port added using PJSUA vidwin pool, the vidwin may get destroyed before the VC port, group lock crashed when iterating handlers).