[vlc-devel] [PATCH] misc/threads: fix cancellation during mwait

Filip Roséen filip at atch.se
Fri Aug 5 21:02:20 CEST 2016


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).

closes #17064
---
 src/misc/threads.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/misc/threads.c b/src/misc/threads.c
index ce3756c..dc8b89f 100644
--- a/src/misc/threads.c
+++ b/src/misc/threads.c
@@ -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);
 }
-- 
2.9.2



More information about the vlc-devel mailing list