Zebediah Figura : rpcrt4: Use a critical section for the context handle lock.

Alexandre Julliard julliard at winehq.org
Tue Jan 28 15:35:26 CST 2020


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

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Mon Jan 27 17:04:11 2020 -0600

rpcrt4: Use a critical section for the context handle lock.

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/rpcrt4/rpc_assoc.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/dlls/rpcrt4/rpc_assoc.c b/dlls/rpcrt4/rpc_assoc.c
index 504f4d66c8..ab865c2de1 100644
--- a/dlls/rpcrt4/rpc_assoc.c
+++ b/dlls/rpcrt4/rpc_assoc.c
@@ -24,7 +24,6 @@
 
 #include "rpc.h"
 #include "rpcndr.h"
-#include "winternl.h"
 
 #include "wine/debug.h"
 
@@ -55,7 +54,7 @@ typedef struct _RpcContextHandle
     NDR_RUNDOWN rundown_routine;
     void *ctx_guard;
     UUID uuid;
-    RTL_RWLOCK rw_lock;
+    CRITICAL_SECTION lock;
     unsigned int refs;
 } RpcContextHandle;
 
@@ -463,12 +462,13 @@ RPC_STATUS RpcServerAssoc_AllocateContextHandle(RpcAssoc *assoc, void *CtxGuard,
         return RPC_S_OUT_OF_MEMORY;
 
     context_handle->ctx_guard = CtxGuard;
-    RtlInitializeResource(&context_handle->rw_lock);
+    InitializeCriticalSection(&context_handle->lock);
+    context_handle->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": RpcContextHandle.lock");
     context_handle->refs = 1;
 
     /* lock here to mirror unmarshall, so we don't need to special-case the
      * freeing of a non-marshalled context handle */
-    RtlAcquireResourceExclusive(&context_handle->rw_lock, TRUE);
+    EnterCriticalSection(&context_handle->lock);
 
     EnterCriticalSection(&assoc->cs);
     list_add_tail(&assoc->context_handle_list, &context_handle->entry);
@@ -500,7 +500,7 @@ RPC_STATUS RpcServerAssoc_FindContextHandle(RpcAssoc *assoc, const UUID *uuid,
             {
                 LeaveCriticalSection(&assoc->cs);
                 TRACE("found %p\n", context_handle);
-                RtlAcquireResourceExclusive(&context_handle->rw_lock, TRUE);
+                EnterCriticalSection(&context_handle->lock);
                 return RPC_S_OK;
             }
         }
@@ -555,7 +555,8 @@ static void RpcContextHandle_Destroy(RpcContextHandle *context_handle)
         context_handle->rundown_routine(context_handle->user_context);
     }
 
-    RtlDeleteResource(&context_handle->rw_lock);
+    context_handle->lock.DebugInfo->Spare[0] = 0;
+    DeleteCriticalSection(&context_handle->lock);
 
     HeapFree(GetProcessHeap(), 0, context_handle);
 }
@@ -566,7 +567,7 @@ unsigned int RpcServerAssoc_ReleaseContextHandle(RpcAssoc *assoc, NDR_SCONTEXT S
     unsigned int refs;
 
     if (release_lock)
-        RtlReleaseResource(&context_handle->rw_lock);
+        LeaveCriticalSection(&context_handle->lock);
 
     EnterCriticalSection(&assoc->cs);
     refs = --context_handle->refs;




More information about the wine-cvs mailing list