diff options
author | wm4 <wm4@nowhere> | 2016-10-30 18:29:24 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2016-10-30 18:29:24 +0100 |
commit | bc77565838bb32074c4798b8e4bf2c912c93c525 (patch) | |
tree | c43245c99e887b0f2546801216d074018885adae | |
parent | b0ef3dd4fb49b8fe111b00ca44c30b9890be0282 (diff) |
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.
-rw-r--r-- | video/out/vo_opengl_cb.c | 6 |
1 files 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; + } } } |