From 17e3e800e1b7bb568ea150fd8182b63966bff509 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 16 Sep 2016 16:11:33 +0200 Subject: dispatch: fix a race condition triggering an assert() 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 8716c2e8. Probably an argument for replacing the dispatch queue by a simple mutex. --- misc/dispatch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'misc') diff --git a/misc/dispatch.c b/misc/dispatch.c index dca39e5fe1..40729d9e8d 100644 --- a/misc/dispatch.c +++ b/misc/dispatch.c @@ -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; } -- cgit v1.2.3