Repository navigation
Fix #574 (deadlocks in player.c) - #710
Merged
Merged
Conversation
mahkoh
force-pushed
the
fix-deadlock
branch
4 times, most recently
from
June 24, 2017 11:44
a71dba6 to
0fa5abb
Compare
These functions allow void functions that would usually block the UI
thread to run in a separate thread. They are accompanied by a series of
macros that easily turn any given void function (with 0 to 3 arguments)
into a function that runs in the aforementioned thread.
For example, consider the following function:
```c
void f(const char *name)
{
printf("Hello %s!\n", name);
sleep(10);
}
```
Applying the macros produces:
```c
DELEGATE_1(f, const char *, name)
{
printf("Hello %s!\n", name);
sleep(10);
}
```
A call to `f` now returns immediately and the function prints and sleeps
in the dedicated thread.
NOTE: There is only one such thread and the call above will block all
other delegated functions for 10 seconds.
In preparation of turning this function into a delegated one.
Instead call it from within ui_curses like the rest of the mpris functions.
This prevents the problem where the UI thread tried to acquire the player lock while the player thread tried to talk to the UI thread. This caused deadlocks. NOTE: Deadlocks can still occur when the player exits because player_exit cannot be delegated.
Member
Author
|
I'm still figuring out some places where the code assumed that the functions were synchronous. |
Member
|
Thanks a lot for the PR! The review can take some time though, sorry about that. |
Member
Author
|
Don't worry about it. It's not done yet though so don't bother with the review yet. |
Contributor
Contributor
|
This has been blocking the release for so long. |
Member
|
True. |
Contributor
|
Please revert this commit. This breaks CoreAudio's mixer initializer. |
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.
Tl;dr: The UI thread no longer waits for the player to perform its requests (player_next, etc.) Instead it simply schedules the commands and returns immediately. This allows the UI thread to reply to
cmus_get_nextrequests that occur while the player holds its locks.Fixes #574.