From 84fe9c2a474e58a69c1b11e6de92107c78598604 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 29 Feb 2020 20:00:21 +0100 Subject: [PATCH] filter: fix possibly lost async wakeups mp_filter_mark_async_progress() can asynchronously mark a filter for processing, without waking up the filter thread. (It's some sort of idiotic micro-optimization I guess?) But since it sets async_pending without doing the wakeup, a mp_filter_wakeup() after this will do nothing, and the wakeup is lost. Fix it by checking for the needed wakeup separately. Fortunately, nothing used this function yet, so there is no impact. --- filters/filter.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/filters/filter.c b/filters/filter.c index beec13c210..84596b723e 100644 --- a/filters/filter.c +++ b/filters/filter.c @@ -614,11 +614,11 @@ static void filter_wakeup(struct mp_filter *f, bool mark_only) f->in->async_pending = true; // (not using a talloc parent for thread safety reasons) MP_TARRAY_APPEND(NULL, r->async_pending, r->num_async_pending, f); - if (!mark_only && !r->async_wakeup_sent) { - if (r->wakeup_cb) - r->wakeup_cb(r->wakeup_ctx); - r->async_wakeup_sent = true; - } + } + if (!mark_only && !r->async_wakeup_sent) { + if (r->wakeup_cb) + r->wakeup_cb(r->wakeup_ctx); + r->async_wakeup_sent = true; } pthread_mutex_unlock(&r->async_lock); }