Jacek Caban : server: Don't wait for client thread to enter suspended state in set_thread_context.
Alexandre Julliard
julliard at winehq.org
Wed Apr 22 15:29:27 CDT 2020
Module: wine
Branch: master
Commit: aa0c4bb5e72caf290b6588bc1f9931cc89a9feb6
URL: https://source.winehq.org/git/wine.git/?a=commit;h=aa0c4bb5e72caf290b6588bc1f9931cc89a9feb6
Author: Jacek Caban <jacek at codeweavers.com>
Date: Wed Apr 22 14:33:09 2020 +0200
server: Don't wait for client thread to enter suspended state in set_thread_context.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ntdll/thread.c | 26 --------------------------
server/thread.c | 22 ++++------------------
2 files changed, 4 insertions(+), 44 deletions(-)
diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c
index ee3c925f91..b8c270c16d 100644
--- a/dlls/ntdll/thread.c
+++ b/dlls/ntdll/thread.c
@@ -787,42 +787,16 @@ TEB_ACTIVE_FRAME * WINAPI RtlGetFrame(void)
NTSTATUS set_thread_context( HANDLE handle, const context_t *context, BOOL *self )
{
NTSTATUS ret;
- DWORD dummy, i;
SERVER_START_REQ( set_thread_context )
{
req->handle = wine_server_obj_handle( handle );
- req->suspend = 1;
wine_server_add_data( req, context, sizeof(*context) );
ret = wine_server_call( req );
*self = reply->self;
}
SERVER_END_REQ;
- if (ret == STATUS_PENDING)
- {
- for (i = 0; i < 100; i++)
- {
- SERVER_START_REQ( set_thread_context )
- {
- req->handle = wine_server_obj_handle( handle );
- req->suspend = 0;
- wine_server_add_data( req, context, sizeof(*context) );
- ret = wine_server_call( req );
- }
- SERVER_END_REQ;
- if (ret == STATUS_PENDING)
- {
- LARGE_INTEGER timeout;
- timeout.QuadPart = -10000;
- NtDelayExecution( FALSE, &timeout );
- }
- else break;
- }
- NtResumeThread( handle, &dummy );
- if (ret == STATUS_PENDING) ret = STATUS_ACCESS_DENIED;
- }
-
return ret;
}
diff --git a/server/thread.c b/server/thread.c
index 07be868d48..de508c6ace 100644
--- a/server/thread.c
+++ b/server/thread.c
@@ -1859,35 +1859,21 @@ DECL_HANDLER(set_thread_context)
if (!(thread = get_thread_from_handle( req->handle, THREAD_SET_CONTEXT ))) return;
reply->self = (thread == current);
- if (thread != current && (!thread->context || thread->context->status == STATUS_PENDING))
- {
- /* thread is not suspended, retry (if it's still running) */
- if (thread->state == RUNNING)
- {
- set_error( STATUS_PENDING );
- if (req->suspend)
- {
- release_object( thread );
- /* make sure we have suspend access */
- if (!(thread = get_thread_from_handle( req->handle, THREAD_SUSPEND_RESUME ))) return;
- suspend_thread( thread );
- }
- }
- else set_error( STATUS_UNSUCCESSFUL );
- }
- else if (context->cpu == thread->process->cpu)
+ if (thread->state == TERMINATED) set_error( STATUS_UNSUCCESSFUL );
+ else if (context->cpu != thread->process->cpu) set_error( STATUS_INVALID_PARAMETER );
+ else
{
unsigned int system_flags = get_context_system_regs(context->cpu) & context->flags;
unsigned int client_flags = context->flags & ~system_flags;
if (system_flags) set_thread_context( thread, context, system_flags );
+ if (thread != current && !get_error()) stop_thread( thread );
if (thread->context && !get_error())
{
copy_context( &thread->context->regs, context, context->flags );
thread->context->regs.flags |= client_flags;
}
}
- else set_error( STATUS_INVALID_PARAMETER );
release_object( thread );
}
More information about the wine-cvs
mailing list