Commit c5bdfdfb authored by Alexandre Julliard's avatar Alexandre Julliard

winedos: Release the 16-bit lock before calling ExitThread.

This avoids deadlocks with the loader lock.
parent a6aa7771
......@@ -352,6 +352,7 @@ extern BOOL WINAPI MZ_Current( void );
extern void WINAPI MZ_AllocDPMITask( void );
extern void WINAPI MZ_RunInThread( PAPCFUNC proc, ULONG_PTR arg );
extern BOOL DOSVM_IsWin16(void);
extern void DOSVM_Exit( WORD retval );
/* dosvm.c */
extern void DOSVM_SendQueuedEvents( CONTEXT86 * );
......
......@@ -4176,7 +4176,7 @@ void WINAPI DOSVM_Int21Handler( CONTEXT86 *context )
case 0x00: /* TERMINATE PROGRAM */
TRACE("TERMINATE PROGRAM\n");
if (DOSVM_IsWin16())
ExitThread( 0 );
DOSVM_Exit( 0 );
else if(ISV86(context))
MZ_Exit( context, FALSE, 0 );
else
......@@ -5050,7 +5050,7 @@ void WINAPI DOSVM_Int21Handler( CONTEXT86 *context )
case 0x4c: /* "EXIT" - TERMINATE WITH RETURN CODE */
TRACE( "EXIT with return code %d\n", AL_reg(context) );
if (DOSVM_IsWin16())
ExitThread( AL_reg(context) );
DOSVM_Exit( AL_reg(context) );
else if(ISV86(context))
MZ_Exit( context, FALSE, AL_reg(context) );
else
......
......@@ -626,11 +626,11 @@ static void StartPM( CONTEXT86 *context )
TRACE( "Protected mode DOS program is terminating\n" );
/*
* FIXME: Instead of calling ExitThread, we should release all
* FIXME: Instead of calling DOSVM_Exit, we should release all
* allocated protected mode resources and call MZ_Exit
* using real mode context. See DPMI specification.
*/
ExitThread( DPMI_retval );
DOSVM_Exit( DPMI_retval );
#if 0
wine_ldt_free_entries( psp->environment, 1 );
......
......@@ -951,7 +951,7 @@ static void WINAPI DOSVM_Int1aHandler( CONTEXT86 *context )
static void WINAPI DOSVM_Int20Handler( CONTEXT86 *context )
{
if (DOSVM_IsWin16())
ExitThread( 0 );
DOSVM_Exit( 0 );
else if(ISV86(context))
MZ_Exit( context, TRUE, 0 );
else
......
......@@ -64,6 +64,18 @@ BOOL DOSVM_IsWin16(void)
return DOSVM_isdosexe ? FALSE : TRUE;
}
/**********************************************************************
* DOSVM_Exit
*/
void DOSVM_Exit( WORD retval )
{
DWORD count;
ReleaseThunkLock( &count );
ExitThread( retval );
}
#ifdef MZ_SUPPORTED
#ifdef HAVE_SYS_MMAN_H
......@@ -731,7 +743,7 @@ void WINAPI MZ_Exit( CONTEXT86 *context, BOOL cs_psp, WORD retval )
} else
TRACE("killing DOS task\n");
}
ExitThread( retval );
DOSVM_Exit( retval );
}
......@@ -785,7 +797,7 @@ void WINAPI MZ_RunInThread( PAPCFUNC proc, ULONG_PTR arg )
*/
void WINAPI MZ_Exit( CONTEXT86 *context, BOOL cs_psp, WORD retval )
{
ExitThread( retval );
DOSVM_Exit( retval );
}
/***********************************************************************
......
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