[vlc-commits] picture_pool: fix cancellation handling with lock

Rémi Denis-Courmont git at videolan.org
Sun Feb 25 20:09:51 CET 2018


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Feb 25 21:06:40 2018 +0200| [362984de0f40d078837e9f1e8db2cbe6c2fd96a5] | committer: Rémi Denis-Courmont

picture_pool: fix cancellation handling with lock

If there is a deprecated lock callback, the mutex might be released
and the cancellation flag much be rechecked.

Conversely, if the pool is empty, then there is no point in checking
the flag: allocation will anyway fail immediately.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=362984de0f40d078837e9f1e8db2cbe6c2fd96a5
---

 src/misc/picture_pool.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/misc/picture_pool.c b/src/misc/picture_pool.c
index e8184e51d9..fd2724cc18 100644
--- a/src/misc/picture_pool.c
+++ b/src/misc/picture_pool.c
@@ -209,16 +209,13 @@ picture_t *picture_pool_Get(picture_pool_t *pool)
     assert(pool->refs > 0);
     available = pool->available;
 
-    if (pool->canceled)
-    {
-        vlc_mutex_unlock(&pool->lock);
-        return NULL;
-    }
-
     while (available != 0)
     {
         int i = ctz(available);
 
+        if (unlikely(pool->canceled))
+            break;
+
         pool->available &= ~(1ULL << i);
         vlc_mutex_unlock(&pool->lock);
         available &= ~(1ULL << i);



More information about the vlc-commits mailing list