Skip to content

Commit

Permalink
dispatch: fix a race condition triggering an assert()
Browse files Browse the repository at this point in the history
If we were waiting, and then exiting due to timeout, we still have to
recheck the condition protected by the condition variable/mutex in order
to get back to a consistent state. In this case, the queue was locked
with mp_dispatch_lock(), and mp_dispatch_queue_process() got to return
without waiting for unlock.

Also caused commit 8716c2e. Probably an argument for replacing the
dispatch queue by a simple mutex.
  • Loading branch information
wm4 committed Sep 16, 2016
1 parent ccf3458 commit 17e3e80
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion misc/dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ void mp_dispatch_queue_process(struct mp_dispatch_queue *queue, double timeout)
} else if (wait > 0 && !queue->interrupted) {
struct timespec ts = mp_time_us_to_timespec(wait);
if (pthread_cond_timedwait(&queue->cond, &queue->lock, &ts))
break;
wait = 0;
} else {
break;
}
Expand Down

0 comments on commit 17e3e80

Please sign in to comment.