[vlc-commits] os2: thread: determine cancelable state with killable variable

KO Myung-Hun git at videolan.org
Wed Dec 2 23:18:10 CET 2015


vlc | branch: master | KO Myung-Hun <komh78 at gmail.com> | Wed Dec  2 09:41:47 2015 +0900| [973a465a5a28ebd9c9bcf860f21e2dca85ee1a9e] | committer: Rémi Denis-Courmont

os2: thread: determine cancelable state with killable variable

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>

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

 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 6635fe7..65a21bc 100644
--- a/src/os2/thread.c
+++ b/src/os2/thread.c
@@ -69,7 +69,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 ];
@@ -78,10 +78,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 );
@@ -117,12 +118,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;
 }



More information about the vlc-commits mailing list