Commit 973a465a authored by KO Myung-Hun's avatar KO Myung-Hun Committed by 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's avatarRémi Denis-Courmont <remi@remlab.net>
parent ddd17286
......@@ -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;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment