From bc77565838bb32074c4798b8e4bf2c912c93c525 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 30 Oct 2016 18:29:24 +0100 Subject: vo_opengl_cb: fix a race condition When pthread_cond_timedwait(), the condition we are checking for could be true or false. This code assumed it was always false. This should be an extremely obscure race condition, since it can happen only if timeout and the condition changing sort of happen at the same time, or the lock is held for a longer time (which it normally isn't). But I could observe it a few times. --- video/out/vo_opengl_cb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/video/out/vo_opengl_cb.c b/video/out/vo_opengl_cb.c index e8c6dfbef8..c66f6d434c 100644 --- a/video/out/vo_opengl_cb.c +++ b/video/out/vo_opengl_cb.c @@ -371,8 +371,10 @@ static void flip_page(struct vo *vo) // Wait until frame was rendered while (p->ctx->next_frame) { if (pthread_cond_timedwait(&p->ctx->wakeup, &p->ctx->lock, &ts)) { - MP_VERBOSE(vo, "mpv_opengl_cb_draw() not being called or stuck.\n"); - goto done; + if (p->ctx->next_frame) { + MP_VERBOSE(vo, "mpv_opengl_cb_draw() not being called or stuck.\n"); + goto done; + } } } -- cgit v1.2.3