Added server_abort_thread to replace SYSDEPS_AbortThread.
Removed no longer used SIGNAL_Block and SIGNAL_Reset. Moved some internal ntdll definitions to ntdll_misc.h.
This commit is contained in:
parent
8574412e1e
commit
4dba172e55
|
@ -47,10 +47,16 @@ extern NTSTATUS NTDLL_wait_for_multiple_objects( UINT count, const HANDLE *handl
|
|||
const LARGE_INTEGER *timeout );
|
||||
|
||||
/* init routines */
|
||||
extern void wine_server_init_process(void);
|
||||
extern void wine_server_init_thread(void);
|
||||
extern BOOL SIGNAL_Init(void);
|
||||
extern void thread_init(void);
|
||||
|
||||
/* server support */
|
||||
extern void server_init_process(void);
|
||||
extern void server_init_thread(void);
|
||||
extern void DECLSPEC_NORETURN server_protocol_error( const char *err, ... );
|
||||
extern void DECLSPEC_NORETURN server_protocol_perror( const char *err );
|
||||
extern void DECLSPEC_NORETURN server_abort_thread( int status );
|
||||
|
||||
/* module handling */
|
||||
extern BOOL MODULE_GetSystemDirectory( UNICODE_STRING *sysdir );
|
||||
extern void RELAY_InitDebugLists(void);
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
#include "ntstatus.h"
|
||||
#include "thread.h"
|
||||
#include "wine/library.h"
|
||||
#include "wine/pthread.h"
|
||||
#include "wine/server.h"
|
||||
#include "winerror.h"
|
||||
#include "ntdll_misc.h"
|
||||
|
@ -110,6 +111,21 @@ static void fatal_perror( const char *err, ... )
|
|||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* server_abort_thread
|
||||
*/
|
||||
void server_abort_thread( int status )
|
||||
{
|
||||
sigprocmask( SIG_BLOCK, &block_set, NULL );
|
||||
close( NtCurrentTeb()->wait_fd[0] );
|
||||
close( NtCurrentTeb()->wait_fd[1] );
|
||||
close( NtCurrentTeb()->reply_fd );
|
||||
close( NtCurrentTeb()->request_fd );
|
||||
wine_pthread_abort_thread( status );
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* server_protocol_error
|
||||
*/
|
||||
|
@ -121,7 +137,7 @@ void server_protocol_error( const char *err, ... )
|
|||
fprintf( stderr, "wine client error:%lx: ", GetCurrentThreadId() );
|
||||
vfprintf( stderr, err, args );
|
||||
va_end( args );
|
||||
SYSDEPS_AbortThread(1);
|
||||
server_abort_thread(1);
|
||||
}
|
||||
|
||||
|
||||
|
@ -132,7 +148,7 @@ void server_protocol_perror( const char *err )
|
|||
{
|
||||
fprintf( stderr, "wine client error:%lx: ", GetCurrentThreadId() );
|
||||
perror( err );
|
||||
SYSDEPS_AbortThread(1);
|
||||
server_abort_thread(1);
|
||||
}
|
||||
|
||||
|
||||
|
@ -167,7 +183,7 @@ static void send_request( const struct __server_request_info *req )
|
|||
}
|
||||
|
||||
if (ret >= 0) server_protocol_error( "partial write %d\n", ret );
|
||||
if (errno == EPIPE) SYSDEPS_AbortThread(0);
|
||||
if (errno == EPIPE) server_abort_thread(0);
|
||||
server_protocol_perror( "sendmsg" );
|
||||
}
|
||||
|
||||
|
@ -195,7 +211,7 @@ static void read_reply_data( void *buffer, size_t size )
|
|||
server_protocol_perror("read");
|
||||
}
|
||||
/* the server closed the connection; time to die... */
|
||||
SYSDEPS_AbortThread(0);
|
||||
server_abort_thread(0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -274,7 +290,7 @@ void wine_server_send_fd( int fd )
|
|||
if ((ret = sendmsg( fd_socket, &msghdr, 0 )) == sizeof(data)) return;
|
||||
if (ret >= 0) server_protocol_error( "partial write %d\n", ret );
|
||||
if (errno == EINTR) continue;
|
||||
if (errno == EPIPE) SYSDEPS_AbortThread(0);
|
||||
if (errno == EPIPE) server_abort_thread(0);
|
||||
server_protocol_perror( "sendmsg" );
|
||||
}
|
||||
}
|
||||
|
@ -333,7 +349,7 @@ static int receive_fd( obj_handle_t *handle )
|
|||
server_protocol_perror("recvmsg");
|
||||
}
|
||||
/* the server closed the connection; time to die... */
|
||||
SYSDEPS_AbortThread(0);
|
||||
server_abort_thread(0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -600,11 +616,11 @@ static int server_connect( const char *oldcwd, const char *serverdir )
|
|||
|
||||
|
||||
/***********************************************************************
|
||||
* wine_server_init_process
|
||||
* server_init_process
|
||||
*
|
||||
* Start the server and create the initial socket pair.
|
||||
*/
|
||||
void wine_server_init_process(void)
|
||||
void server_init_process(void)
|
||||
{
|
||||
int size;
|
||||
char *oldcwd;
|
||||
|
@ -646,11 +662,11 @@ void wine_server_init_process(void)
|
|||
|
||||
|
||||
/***********************************************************************
|
||||
* wine_server_init_thread
|
||||
* server_init_thread
|
||||
*
|
||||
* Send an init thread request. Return 0 if OK.
|
||||
*/
|
||||
void wine_server_init_thread(void)
|
||||
void server_init_thread(void)
|
||||
{
|
||||
TEB *teb = NtCurrentTeb();
|
||||
int version, ret;
|
||||
|
|
|
@ -663,7 +663,7 @@ static EXCEPTION_RECORD *setup_exception( SIGCONTEXT *sigcontext, raise_func fun
|
|||
ERR( "nested exception on signal stack in thread %04lx eip %08lx esp %08lx stack %p-%p\n",
|
||||
GetCurrentThreadId(), EIP_sig(sigcontext), ESP_sig(sigcontext),
|
||||
NtCurrentTeb()->Tib.StackLimit, NtCurrentTeb()->Tib.StackBase );
|
||||
SYSDEPS_AbortThread(1);
|
||||
server_abort_thread(1);
|
||||
}
|
||||
|
||||
if ((char *)(stack - 1) < (char *)NtCurrentTeb()->Tib.StackLimit + 4096 ||
|
||||
|
@ -675,7 +675,7 @@ static EXCEPTION_RECORD *setup_exception( SIGCONTEXT *sigcontext, raise_func fun
|
|||
ERR( "stack overflow %u bytes in thread %04lx eip %08lx esp %08lx stack %p-%p\n",
|
||||
diff, GetCurrentThreadId(), EIP_sig(sigcontext), ESP_sig(sigcontext),
|
||||
NtCurrentTeb()->Tib.StackLimit, NtCurrentTeb()->Tib.StackBase );
|
||||
SYSDEPS_AbortThread(1);
|
||||
server_abort_thread(1);
|
||||
}
|
||||
else WARN( "exception outside of stack limits in thread %04lx eip %08lx esp %08lx stack %p-%p\n",
|
||||
GetCurrentThreadId(), EIP_sig(sigcontext), ESP_sig(sigcontext),
|
||||
|
@ -1057,7 +1057,7 @@ static HANDLER_DEF(abrt_handler)
|
|||
static HANDLER_DEF(term_handler)
|
||||
{
|
||||
init_handler( HANDLER_CONTEXT );
|
||||
SYSDEPS_AbortThread(0);
|
||||
server_abort_thread(0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1178,46 +1178,6 @@ BOOL SIGNAL_Init(void)
|
|||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* SIGNAL_Block
|
||||
*
|
||||
* Block the async signals.
|
||||
*/
|
||||
void SIGNAL_Block(void)
|
||||
{
|
||||
sigset_t block_set;
|
||||
|
||||
sigemptyset( &block_set );
|
||||
sigaddset( &block_set, SIGIO );
|
||||
sigaddset( &block_set, SIGHUP );
|
||||
sigaddset( &block_set, SIGUSR1 );
|
||||
sigaddset( &block_set, SIGUSR2 );
|
||||
sigprocmask( SIG_BLOCK, &block_set, NULL );
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* SIGNAL_Reset
|
||||
*
|
||||
* Restore the default handlers.
|
||||
*/
|
||||
void SIGNAL_Reset(void)
|
||||
{
|
||||
signal( SIGINT, SIG_DFL );
|
||||
signal( SIGFPE, SIG_DFL );
|
||||
signal( SIGSEGV, SIG_DFL );
|
||||
signal( SIGILL, SIG_DFL );
|
||||
signal( SIGABRT, SIG_DFL );
|
||||
signal( SIGTERM, SIG_DFL );
|
||||
#ifdef SIGBUS
|
||||
signal( SIGBUS, SIG_DFL );
|
||||
#endif
|
||||
#ifdef SIGTRAP
|
||||
signal( SIGTRAP, SIG_DFL );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifdef __HAVE_VM86
|
||||
/**********************************************************************
|
||||
* __wine_enter_vm86 (NTDLL.@)
|
||||
|
|
|
@ -572,7 +572,7 @@ static HANDLER_DEF(abrt_handler)
|
|||
*/
|
||||
static HANDLER_DEF(term_handler)
|
||||
{
|
||||
SYSDEPS_AbortThread(0);
|
||||
server_abort_thread(0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -649,47 +649,6 @@ BOOL SIGNAL_Init(void)
|
|||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* SIGNAL_Block
|
||||
*
|
||||
* Block the async signals.
|
||||
*/
|
||||
void SIGNAL_Block(void)
|
||||
{
|
||||
sigset_t block_set;
|
||||
|
||||
sigemptyset( &block_set );
|
||||
sigaddset( &block_set, SIGALRM );
|
||||
sigaddset( &block_set, SIGIO );
|
||||
sigaddset( &block_set, SIGHUP );
|
||||
sigaddset( &block_set, SIGUSR1 );
|
||||
sigaddset( &block_set, SIGUSR2 );
|
||||
sigprocmask( SIG_BLOCK, &block_set, NULL );
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* SIGNAL_Reset
|
||||
*
|
||||
* Restore the default handlers.
|
||||
*/
|
||||
void SIGNAL_Reset(void)
|
||||
{
|
||||
signal( SIGINT, SIG_DFL );
|
||||
signal( SIGFPE, SIG_DFL );
|
||||
signal( SIGSEGV, SIG_DFL );
|
||||
signal( SIGILL, SIG_DFL );
|
||||
signal( SIGABRT, SIG_DFL );
|
||||
signal( SIGTERM, SIG_DFL );
|
||||
#ifdef SIGBUS
|
||||
signal( SIGBUS, SIG_DFL );
|
||||
#endif
|
||||
#ifdef SIGTRAP
|
||||
signal( SIGTRAP, SIG_DFL );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* __wine_enter_vm86 (NTDLL.@)
|
||||
*/
|
||||
|
|
|
@ -376,7 +376,7 @@ static HANDLER_DEF(abrt_handler)
|
|||
*/
|
||||
static HANDLER_DEF(term_handler)
|
||||
{
|
||||
SYSDEPS_AbortThread(0);
|
||||
server_abort_thread(0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -447,43 +447,6 @@ BOOL SIGNAL_Init(void)
|
|||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* SIGNAL_Block
|
||||
*
|
||||
* Block the async signals.
|
||||
*/
|
||||
void SIGNAL_Block(void)
|
||||
{
|
||||
sigset_t block_set;
|
||||
|
||||
sigemptyset( &block_set );
|
||||
sigaddset( &block_set, SIGALRM );
|
||||
sigaddset( &block_set, SIGIO );
|
||||
sigaddset( &block_set, SIGHUP );
|
||||
sigaddset( &block_set, SIGUSR1 );
|
||||
sigaddset( &block_set, SIGUSR2 );
|
||||
sigprocmask( SIG_BLOCK, &block_set, NULL );
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* SIGNAL_Reset
|
||||
*
|
||||
* Restore the default handlers.
|
||||
*/
|
||||
void SIGNAL_Reset(void)
|
||||
{
|
||||
signal( SIGINT, SIG_DFL );
|
||||
signal( SIGFPE, SIG_DFL );
|
||||
signal( SIGSEGV, SIG_DFL );
|
||||
signal( SIGILL, SIG_DFL );
|
||||
signal( SIGBUS, SIG_DFL );
|
||||
signal( SIGTRAP, SIG_DFL );
|
||||
signal( SIGABRT, SIG_DFL );
|
||||
signal( SIGTERM, SIG_DFL );
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* __wine_enter_vm86
|
||||
*/
|
||||
|
|
|
@ -496,7 +496,7 @@ static int wait_reply( void *cookie )
|
|||
server_protocol_perror("wakeup read");
|
||||
}
|
||||
/* the server closed the connection; time to die... */
|
||||
SYSDEPS_AbortThread(0);
|
||||
server_abort_thread(0);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -86,21 +86,6 @@ void SYSDEPS_SetCurThread( TEB *teb )
|
|||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* SYSDEPS_AbortThread
|
||||
*
|
||||
* Same as SYSDEPS_ExitThread, but must not do anything that requires a server call.
|
||||
*/
|
||||
void SYSDEPS_AbortThread( int status )
|
||||
{
|
||||
SIGNAL_Block();
|
||||
close( NtCurrentTeb()->wait_fd[0] );
|
||||
close( NtCurrentTeb()->wait_fd[1] );
|
||||
close( NtCurrentTeb()->reply_fd );
|
||||
close( NtCurrentTeb()->request_fd );
|
||||
wine_pthread_abort_thread( status );
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* SYSDEPS_GetUnixTid
|
||||
*
|
||||
|
|
|
@ -42,7 +42,6 @@ static PEB_LDR_DATA ldr;
|
|||
static RTL_USER_PROCESS_PARAMETERS params; /* default parameters if no parent */
|
||||
static RTL_BITMAP tls_bitmap;
|
||||
static LIST_ENTRY tls_links;
|
||||
static struct debug_info info; /* debug info for initial thread */
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
|
@ -96,9 +95,10 @@ void thread_init(void)
|
|||
TEB *teb;
|
||||
void *addr;
|
||||
ULONG size;
|
||||
static struct debug_info debug_info; /* debug info for initial thread */
|
||||
|
||||
info.str_pos = info.strings;
|
||||
info.out_pos = info.output;
|
||||
debug_info.str_pos = debug_info.strings;
|
||||
debug_info.out_pos = debug_info.output;
|
||||
|
||||
peb.ProcessParameters = ¶ms;
|
||||
peb.TlsBitmap = &tls_bitmap;
|
||||
|
@ -115,14 +115,14 @@ void thread_init(void)
|
|||
teb->reply_fd = -1;
|
||||
teb->wait_fd[0] = -1;
|
||||
teb->wait_fd[1] = -1;
|
||||
teb->debug_info = &info;
|
||||
teb->debug_info = &debug_info;
|
||||
InsertHeadList( &tls_links, &teb->TlsLinks );
|
||||
|
||||
SYSDEPS_SetCurThread( teb );
|
||||
|
||||
/* setup the server connection */
|
||||
wine_server_init_process();
|
||||
wine_server_init_thread();
|
||||
server_init_process();
|
||||
server_init_thread();
|
||||
|
||||
/* create a memory view for the TEB */
|
||||
NtAllocateVirtualMemory( GetCurrentProcess(), &addr, teb, &size,
|
||||
|
@ -155,7 +155,7 @@ static void start_thread( struct wine_pthread_thread_info *info )
|
|||
|
||||
SYSDEPS_SetCurThread( teb );
|
||||
SIGNAL_Init();
|
||||
wine_server_init_thread();
|
||||
server_init_thread();
|
||||
|
||||
/* allocate a memory view for the stack */
|
||||
size = info->stack_size;
|
||||
|
@ -359,7 +359,7 @@ NTSTATUS WINAPI NtTerminateThread( HANDLE handle, LONG exit_code )
|
|||
if (self)
|
||||
{
|
||||
if (last) exit( exit_code );
|
||||
else SYSDEPS_AbortThread( exit_code );
|
||||
else server_abort_thread( exit_code );
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -144,15 +144,7 @@ typedef struct _TEB
|
|||
extern TEB *THREAD_InitStack( TEB *teb, DWORD stack_size );
|
||||
|
||||
/* scheduler/sysdeps.c */
|
||||
extern int SYSDEPS_SpawnThread( void (*func)(TEB *), TEB *teb );
|
||||
extern void SYSDEPS_SetCurThread( TEB *teb );
|
||||
extern int SYSDEPS_GetUnixTid(void);
|
||||
extern void DECLSPEC_NORETURN SYSDEPS_ExitThread( int status );
|
||||
extern void DECLSPEC_NORETURN SYSDEPS_AbortThread( int status );
|
||||
|
||||
/* signal handling */
|
||||
extern BOOL SIGNAL_Init(void);
|
||||
extern void SIGNAL_Block(void);
|
||||
extern void SIGNAL_Reset(void);
|
||||
|
||||
#endif /* __WINE_THREAD_H */
|
||||
|
|
|
@ -110,8 +110,4 @@ inline static void wine_server_set_reply( void *req_ptr, void *ptr, unsigned int
|
|||
} while(0)
|
||||
|
||||
|
||||
/* non-exported functions */
|
||||
extern void DECLSPEC_NORETURN server_protocol_error( const char *err, ... );
|
||||
extern void DECLSPEC_NORETURN server_protocol_perror( const char *err );
|
||||
|
||||
#endif /* __WINE_WINE_SERVER_H */
|
||||
|
|
Loading…
Reference in New Issue