Jacek Caban : ntdll: Use select request to pass suspend context to server.

Alexandre Julliard julliard at winehq.org
Thu Apr 16 16:45:14 CDT 2020


Module: wine
Branch: master
Commit: 5e7ccd182e7dbcf2ef531835c6a87ad672641056
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=5e7ccd182e7dbcf2ef531835c6a87ad672641056

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Wed Apr 15 14:55:14 2020 +0200

ntdll: Use select request to pass suspend context to server.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/exception.c  | 14 ++------------
 dlls/ntdll/ntdll_misc.h |  2 +-
 dlls/ntdll/server.c     | 16 ++++++++++++++--
 dlls/ntdll/sync.c       |  2 +-
 4 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/dlls/ntdll/exception.c b/dlls/ntdll/exception.c
index 7854ad97c6..fe3af73d34 100644
--- a/dlls/ntdll/exception.c
+++ b/dlls/ntdll/exception.c
@@ -115,18 +115,8 @@ void wait_suspend( CONTEXT *context )
     context_t server_context;
     DWORD flags = context->ContextFlags;
 
-    context_to_server( &server_context, context );
-
-    /* store the context we got at suspend time */
-    SERVER_START_REQ( set_suspend_context )
-    {
-        wine_server_add_data( req, &server_context, sizeof(server_context) );
-        wine_server_call( req );
-    }
-    SERVER_END_REQ;
-
     /* wait with 0 timeout, will only return once the thread is no longer suspended */
-    server_select( NULL, 0, SELECT_INTERRUPTIBLE, 0, NULL );
+    server_select( NULL, 0, SELECT_INTERRUPTIBLE, 0, context, NULL );
 
     /* retrieve the new context */
     SERVER_START_REQ( get_suspend_context )
@@ -183,7 +173,7 @@ NTSTATUS send_debug_event( EXCEPTION_RECORD *rec, int first_chance, CONTEXT *con
 
     select_op.wait.op = SELECT_WAIT;
     select_op.wait.handles[0] = handle;
-    server_select( &select_op, offsetof( select_op_t, wait.handles[1] ), SELECT_INTERRUPTIBLE, TIMEOUT_INFINITE, NULL );
+    server_select( &select_op, offsetof( select_op_t, wait.handles[1] ), SELECT_INTERRUPTIBLE, TIMEOUT_INFINITE, NULL, NULL );
 
     SERVER_START_REQ( get_exception_status )
     {
diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h
index f18ab1f227..336d7c0463 100644
--- a/dlls/ntdll/ntdll_misc.h
+++ b/dlls/ntdll/ntdll_misc.h
@@ -117,7 +117,7 @@ extern unsigned int server_call_unlocked( void *req_ptr ) DECLSPEC_HIDDEN;
 extern void server_enter_uninterrupted_section( RTL_CRITICAL_SECTION *cs, sigset_t *sigset ) DECLSPEC_HIDDEN;
 extern void server_leave_uninterrupted_section( RTL_CRITICAL_SECTION *cs, sigset_t *sigset ) DECLSPEC_HIDDEN;
 extern unsigned int server_select( const select_op_t *select_op, data_size_t size, UINT flags,
-                                   timeout_t abs_timeout, user_apc_t *user_apc ) DECLSPEC_HIDDEN;
+                                   timeout_t abs_timeout, CONTEXT *context, user_apc_t *user_apc ) DECLSPEC_HIDDEN;
 extern unsigned int server_wait( const select_op_t *select_op, data_size_t size,
                                  UINT flags, const LARGE_INTEGER *timeout ) DECLSPEC_HIDDEN;
 extern unsigned int server_queue_process_apc( HANDLE process, const apc_call_t *call, apc_result_t *result ) DECLSPEC_HIDDEN;
diff --git a/dlls/ntdll/server.c b/dlls/ntdll/server.c
index 7e178aa745..9103941e1b 100644
--- a/dlls/ntdll/server.c
+++ b/dlls/ntdll/server.c
@@ -602,16 +602,23 @@ static void invoke_system_apc( const apc_call_t *call, apc_result_t *result )
  *              server_select
  */
 unsigned int server_select( const select_op_t *select_op, data_size_t size, UINT flags,
-                            timeout_t abs_timeout, user_apc_t *user_apc )
+                            timeout_t abs_timeout, CONTEXT *context, user_apc_t *user_apc )
 {
     unsigned int ret;
     int cookie;
     obj_handle_t apc_handle = 0;
+    context_t server_context;
+    BOOL suspend_context = FALSE;
     apc_call_t call;
     apc_result_t result;
     sigset_t old_set;
 
     memset( &result, 0, sizeof(result) );
+    if (context)
+    {
+        suspend_context = TRUE;
+        context_to_server( &server_context, context );
+    }
 
     do
     {
@@ -627,6 +634,11 @@ unsigned int server_select( const select_op_t *select_op, data_size_t size, UINT
                 req->size     = size;
                 wine_server_add_data( req, &result, sizeof(result) );
                 wine_server_add_data( req, select_op, size );
+                if (suspend_context)
+                {
+                    wine_server_add_data( req, &server_context, sizeof(server_context) );
+                    suspend_context = FALSE; /* server owns the context now */
+                }
                 ret = server_call_unlocked( req );
                 apc_handle  = reply->apc_handle;
                 call        = reply->call;
@@ -673,7 +685,7 @@ unsigned int server_wait( const select_op_t *select_op, data_size_t size, UINT f
 
     for (;;)
     {
-        ret = server_select( select_op, size, flags, abs_timeout, &apc );
+        ret = server_select( select_op, size, flags, abs_timeout, NULL, &apc );
         if (ret != STATUS_USER_APC) break;
         invoke_apc( &apc );
 
diff --git a/dlls/ntdll/sync.c b/dlls/ntdll/sync.c
index eaee7030de..be00ac75d0 100644
--- a/dlls/ntdll/sync.c
+++ b/dlls/ntdll/sync.c
@@ -2585,7 +2585,7 @@ NTSTATUS WINAPI RtlWaitOnAddress( const void *addr, const void *cmp, SIZE_T size
         if (!compare_addr( addr, cmp, size ))
             ret = STATUS_SUCCESS;
         else
-            ret = server_select( &select_op, sizeof(select_op.keyed_event), SELECT_INTERRUPTIBLE, abs_timeout, &apc );
+            ret = server_select( &select_op, sizeof(select_op.keyed_event), SELECT_INTERRUPTIBLE, abs_timeout, NULL, &apc );
         RtlLeaveCriticalSection( &addr_section );
 
         if (ret != STATUS_USER_APC) break;




More information about the wine-cvs mailing list