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

Filip Roséen git at videolan.org
Fri Aug 5 22:14:01 CEST 2016


vlc | branch: master | Filip Roséen <filip at atch.se> | Fri Aug  5 21:02:20 2016 +0200| [1fe78e0888bef91722f0c952e5629d40f0298ec2] | committer: Rémi Denis-Courmont

misc/threads: fix cancellation during mwait

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 at remlab.net>

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

 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);
 }



More information about the vlc-commits mailing list