mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-05 15:39:42 +00:00
Fixed various stupid bugs in services thread routines.
Added SERVICE_Exit routine to kill the services thread.
This commit is contained in:
parent
739c318fff
commit
70b2e383a0
|
@ -11,6 +11,8 @@
|
|||
|
||||
BOOL SERVICE_Init( void );
|
||||
|
||||
void SERVICE_Exit( void );
|
||||
|
||||
HANDLE SERVICE_AddObject( HANDLE object,
|
||||
PAPCFUNC callback, ULONG_PTR callback_arg );
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "debugtools.h"
|
||||
#include "dosexe.h"
|
||||
#include "dde_proc.h"
|
||||
#include "services.h"
|
||||
#include "server.h"
|
||||
|
||||
DECLARE_DEBUG_CHANNEL(relay)
|
||||
|
@ -579,6 +580,7 @@ void TASK_KillTask( HTASK16 hTask )
|
|||
if (nTaskCount <= 1)
|
||||
{
|
||||
TRACE_(task)("this is the last task, exiting\n" );
|
||||
SERVICE_Exit();
|
||||
USER_ExitWindows();
|
||||
}
|
||||
|
||||
|
|
|
@ -100,6 +100,7 @@ static DWORD CALLBACK SERVICE_Loop( SERVICETABLE *service )
|
|||
if ( retval >= WAIT_OBJECT_0 && retval < WAIT_OBJECT_0 + count )
|
||||
if ( handles[retval - WAIT_OBJECT_0] == s->object )
|
||||
{
|
||||
retval = WAIT_TIMEOUT;
|
||||
callback = s->callback;
|
||||
callback_arg = s->callback_arg;
|
||||
break;
|
||||
|
@ -139,7 +140,8 @@ static DWORD CALLBACK SERVICE_Loop( SERVICETABLE *service )
|
|||
continue;
|
||||
|
||||
if ( s->flags & SERVICE_USE_OBJECT )
|
||||
handles[count++] = s->object;
|
||||
if ( count < MAXIMUM_WAIT_OBJECTS )
|
||||
handles[count++] = s->object;
|
||||
|
||||
if ( s->flags & SERVICE_USE_TIMEOUT )
|
||||
{
|
||||
|
@ -199,6 +201,14 @@ BOOL SERVICE_Init( void )
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* SERVICE_Exit
|
||||
*/
|
||||
void SERVICE_Exit( void )
|
||||
{
|
||||
TerminateThread( Service->thread, 0 );
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* SERVICE_AddObject
|
||||
*/
|
||||
|
@ -208,6 +218,8 @@ HANDLE SERVICE_AddObject( HANDLE object,
|
|||
SERVICE *s;
|
||||
HANDLE handle;
|
||||
|
||||
object = ConvertToGlobalHandle( object ); /* FIXME */
|
||||
|
||||
if ( !Service || object == INVALID_HANDLE_VALUE || !callback )
|
||||
return INVALID_HANDLE_VALUE;
|
||||
|
||||
|
@ -273,8 +285,9 @@ HANDLE SERVICE_AddTimer( LONG rate,
|
|||
*/
|
||||
BOOL SERVICE_Delete( HANDLE service )
|
||||
{
|
||||
HANDLE handle = INVALID_HANDLE_VALUE;
|
||||
BOOL retv = TRUE;
|
||||
SERVICE **s;
|
||||
SERVICE **s, *next;
|
||||
|
||||
if ( !Service ) return retv;
|
||||
|
||||
|
@ -283,14 +296,21 @@ BOOL SERVICE_Delete( HANDLE service )
|
|||
for ( s = &Service->first; *s; s = &(*s)->next )
|
||||
if ( (*s)->self == service )
|
||||
{
|
||||
*s = (*s)->next;
|
||||
if ( (*s)->flags & SERVICE_USE_OBJECT )
|
||||
handle = (*s)->object;
|
||||
|
||||
next = (*s)->next;
|
||||
HeapFree( Service->heap, 0, *s );
|
||||
*s = next;
|
||||
retv = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
HeapUnlock( Service->heap );
|
||||
|
||||
if ( handle != INVALID_HANDLE_VALUE )
|
||||
CloseHandle( handle );
|
||||
|
||||
QueueUserAPC( NULL, Service->thread, 0L );
|
||||
|
||||
return retv;
|
||||
|
|
Loading…
Reference in a new issue