[vlc-commits] linux: fix vlc_futex_wait() cancellation

Rémi Denis-Courmont git at videolan.org
Tue Feb 4 19:02:04 CET 2020


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Feb  3 21:23:49 2020 +0200| [28f8c56d8ea7a0027964642148f018020a6fbf0d] | committer: Rémi Denis-Courmont

linux: fix vlc_futex_wait() cancellation

As things stood, it works on Android (where the code is actually used)
but not on desktop. There is a latent bug where cancellation is not
acted up, leading to dead locks.

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

 src/linux/thread.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/linux/thread.c b/src/linux/thread.c
index 539c64f147..7e9dab63bd 100644
--- a/src/linux/thread.c
+++ b/src/linux/thread.c
@@ -60,7 +60,12 @@ static int vlc_futex_wake(void *addr, int nr)
 
 static int vlc_futex_wait(void *addr, unsigned val, const struct timespec *to)
 {
-    return sys_futex(addr, FUTEX_WAIT_PRIVATE, val, to, NULL, 0);
+    int ret, type;
+
+    pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &type);
+    ret = sys_futex(addr, FUTEX_WAIT_PRIVATE, val, to, NULL, 0);
+    pthread_setcanceltype(type, NULL);
+    return ret;
 }
 
 void vlc_addr_signal(void *addr)



More information about the vlc-commits mailing list