misc/threads: fix cancellation during mwait
authorFilip Roséen <filip@atch.se>
Fri, 5 Aug 2016 19:02:20 +0000 (21:02 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Fri, 5 Aug 2016 20:13:18 +0000 (23:13 +0300)
Prior to this patch the while-loop in src/misc/threads.c:mwait would
keep on spinning until the deadline has been reached, no matter if
vlc_addr_timedwait woke up due to the thread being canceled.

This commit makes sure that we check whether or not the thread has
been canceled, through vlc_testcancel, when vlc_addr_timedwait returns
(in order to also take spurious wake-ups into account).

Signed-off-by: Rémi Denis-Courmont <remi@remlab.net>
src/misc/threads.c

index ce3756c..dc8b89f 100644 (file)
@@ -85,7 +85,10 @@ void (mwait)(mtime_t deadline)
     vlc_cancel_addr_prepare(&value);
 
     while ((delay = (deadline - mdate())) > 0)
+    {
         vlc_addr_timedwait(&value, 0, delay);
+        vlc_testcancel();
+    }
 
     vlc_cancel_addr_finish(&value);
 }