ntdll: Don't call terminate_thread request if not necessary.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
feature/deterministic
Alexandre Julliard 2020-05-29 12:25:16 +02:00
parent 116890da12
commit 42bd67b576
6 changed files with 13 additions and 20 deletions

View File

@ -738,17 +738,19 @@ NTSTATUS WINAPI NtAlertThread( HANDLE handle )
NTSTATUS WINAPI NtTerminateThread( HANDLE handle, LONG exit_code )
{
NTSTATUS ret;
BOOL self;
BOOL self = (handle == GetCurrentThread());
SERVER_START_REQ( terminate_thread )
if (!self || exit_code)
{
req->handle = wine_server_obj_handle( handle );
req->exit_code = exit_code;
ret = wine_server_call( req );
self = !ret && reply->self;
SERVER_START_REQ( terminate_thread )
{
req->handle = wine_server_obj_handle( handle );
req->exit_code = exit_code;
ret = wine_server_call( req );
self = !ret && reply->self;
}
SERVER_END_REQ;
}
SERVER_END_REQ;
if (self) abort_thread( exit_code );
return ret;
}

View File

@ -938,7 +938,7 @@ struct terminate_thread_reply
{
struct reply_header __header;
int self;
int last;
char __pad_12[4];
};
@ -6685,7 +6685,7 @@ union generic_reply
/* ### protocol_version begin ### */
#define SERVER_PROTOCOL_VERSION 604
#define SERVER_PROTOCOL_VERSION 605
/* ### protocol_version end ### */

View File

@ -896,7 +896,6 @@ struct rawinput_device
int exit_code; /* thread exit code */
@REPLY
int self; /* suicide? */
int last; /* last thread in this process? */
@END

View File

@ -814,7 +814,6 @@ C_ASSERT( FIELD_OFFSET(struct terminate_thread_request, handle) == 12 );
C_ASSERT( FIELD_OFFSET(struct terminate_thread_request, exit_code) == 16 );
C_ASSERT( sizeof(struct terminate_thread_request) == 24 );
C_ASSERT( FIELD_OFFSET(struct terminate_thread_reply, self) == 8 );
C_ASSERT( FIELD_OFFSET(struct terminate_thread_reply, last) == 12 );
C_ASSERT( sizeof(struct terminate_thread_reply) == 16 );
C_ASSERT( FIELD_OFFSET(struct get_process_info_request, handle) == 12 );
C_ASSERT( sizeof(struct get_process_info_request) == 16 );

View File

@ -1489,17 +1489,11 @@ DECL_HANDLER(terminate_thread)
{
struct thread *thread;
reply->self = 0;
reply->last = 0;
if ((thread = get_thread_from_handle( req->handle, THREAD_TERMINATE )))
{
thread->exit_code = req->exit_code;
if (thread != current) kill_thread( thread, 1 );
else
{
reply->self = 1;
reply->last = (thread->process->running_threads == 1);
}
else reply->self = 1;
release_object( thread );
}
}

View File

@ -1368,7 +1368,6 @@ static void dump_terminate_thread_request( const struct terminate_thread_request
static void dump_terminate_thread_reply( const struct terminate_thread_reply *req )
{
fprintf( stderr, " self=%d", req->self );
fprintf( stderr, ", last=%d", req->last );
}
static void dump_get_process_info_request( const struct get_process_info_request *req )