[vlc-devel] [PATCH 4/4] os2: thread: determine cancelable state with killable variable
KO Myung-Hun
komh78 at gmail.com
Sun Dec 6 10:57:41 CET 2015
From: KO Myung-Hun <komh78 at gmail.com>
If thread cancel is disabled and cancel is requested, it causes a tight
infinite loop eating up CPU in cancellation points such as vlc_join(),
vlc_cond_wait() and vlc_cond_timedwait().
Signed-off-by: Rémi Denis-Courmont <remi at remlab.net>
(cherry picked from commit 973a465a5a28ebd9c9bcf860f21e2dca85ee1a9e)
Signed-off-by: KO Myung-Hun <komh at chollian.net>
---
src/os2/thread.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/os2/thread.c b/src/os2/thread.c
index be2b94c..f6cf19f 100644
--- a/src/os2/thread.c
+++ b/src/os2/thread.c
@@ -70,7 +70,7 @@ struct vlc_thread
static void vlc_cancel_self (PVOID dummy);
-static ULONG vlc_DosWaitEventSemEx( HEV hev, ULONG ulTimeout, BOOL fCancelable )
+static ULONG vlc_DosWaitEventSemEx( HEV hev, ULONG ulTimeout )
{
HMUX hmux;
SEMRECORD asr[ 2 ];
@@ -79,10 +79,11 @@ static ULONG vlc_DosWaitEventSemEx( HEV hev, ULONG ulTimeout, BOOL fCancelable )
ULONG rc;
struct vlc_thread *th = vlc_threadvar_get( thread_key );
- if( th == NULL || !fCancelable )
+ if( th == NULL || !th->killable )
{
/* Main thread - cannot be cancelled anyway
* Alien thread - out of our control
+ * Cancel disabled thread - ignore cancel
*/
if( hev != NULLHANDLE )
return DosWaitEventSem( hev, ulTimeout );
@@ -118,12 +119,12 @@ static ULONG vlc_DosWaitEventSemEx( HEV hev, ULONG ulTimeout, BOOL fCancelable )
static ULONG vlc_WaitForSingleObject (HEV hev, ULONG ulTimeout)
{
- return vlc_DosWaitEventSemEx( hev, ulTimeout, TRUE );
+ return vlc_DosWaitEventSemEx( hev, ulTimeout );
}
static ULONG vlc_Sleep (ULONG ulTimeout)
{
- ULONG rc = vlc_DosWaitEventSemEx( NULLHANDLE, ulTimeout, TRUE );
+ ULONG rc = vlc_DosWaitEventSemEx( NULLHANDLE, ulTimeout );
return ( rc != ERROR_TIMEOUT ) ? rc : 0;
}
--
2.6.0
More information about the vlc-devel
mailing list