mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-29 05:40:23 -04:00
thread-test: fix deadlock
If we set magic_number to zero, the code will deadlock, because the thread that is waiting for us to set magic_number to non-zero will never progress. The problem was reported here: https://lists.freedesktop.org/archives/pulseaudio-discuss/2017-January/027368.html
This commit is contained in:
parent
a50030b697
commit
5e1bb023a2
1 changed files with 4 additions and 1 deletions
|
|
@ -115,7 +115,10 @@ START_TEST (thread_test) {
|
|||
for (k = 0; k < 100; k++) {
|
||||
pa_assert(magic_number == 0);
|
||||
|
||||
magic_number = (int) rand() % 0x10000;
|
||||
/* There's a thread waiting for us to change magic_number to a non-zero
|
||||
* value. The "+ 1" part ensures that we don't accidentally set
|
||||
* magic_number to zero here. */
|
||||
magic_number = (int) rand() % 0x10000 + 1;
|
||||
|
||||
pa_log_info("iteration %i (%i)", k, magic_number);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue