[PATCH 1/2] rpcrt4: Don't nest critical sections to prevent a deadlock (Coverity).
Sven Baars
sven.wine at gmail.com
Mon Oct 21 16:49:49 CDT 2019
Signed-off-by: Sven Baars <sven.wine at gmail.com>
---
dlls/rpcrt4/rpc_server.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/dlls/rpcrt4/rpc_server.c b/dlls/rpcrt4/rpc_server.c
index 12260b7298..b5110c879c 100644
--- a/dlls/rpcrt4/rpc_server.c
+++ b/dlls/rpcrt4/rpc_server.c
@@ -1558,12 +1558,16 @@ RPC_STATUS WINAPI RpcMgmtWaitServerListen( void )
WaitForSingleObject( event, INFINITE );
TRACE( "done waiting\n" );
- EnterCriticalSection(&listen_cs);
/* wait for server threads to finish */
while(1)
{
+ EnterCriticalSection(&listen_cs);
if (listen_count)
+ {
+ LeaveCriticalSection(&listen_cs);
break;
+ }
+ LeaveCriticalSection(&listen_cs);
wait_thread = NULL;
EnterCriticalSection(&server_cs);
@@ -1577,10 +1581,9 @@ RPC_STATUS WINAPI RpcMgmtWaitServerListen( void )
break;
TRACE("waiting for thread %u\n", GetThreadId(wait_thread));
- LeaveCriticalSection(&listen_cs);
WaitForSingleObject(wait_thread, INFINITE);
- EnterCriticalSection(&listen_cs);
}
+ EnterCriticalSection(&listen_cs);
if (listen_done_event == event)
{
listen_done_event = NULL;
--
2.17.1
More information about the wine-devel
mailing list