diff --git a/dlls/rpcrt4/rpc_server.c b/dlls/rpcrt4/rpc_server.c index f93d264a79f..7a3a5f62449 100644 --- a/dlls/rpcrt4/rpc_server.c +++ b/dlls/rpcrt4/rpc_server.c @@ -147,10 +147,11 @@ static RpcServerInterface* RPCRT4_find_interface(UUID* object, static void RPCRT4_release_server_interface(RpcServerInterface *sif) { if (!InterlockedDecrement(&sif->CurrentCalls) && - sif->CallsCompletedEvent) { + sif->Delete) { /* sif must have been removed from server_interfaces before * CallsCompletedEvent is set */ - SetEvent(sif->CallsCompletedEvent); + if (sif->CallsCompletedEvent) + SetEvent(sif->CallsCompletedEvent); HeapFree(GetProcessHeap(), 0, sif); } } @@ -888,8 +889,10 @@ RPC_STATUS WINAPI RpcServerUnregisterIf( RPC_IF_HANDLE IfSpec, UUID* MgrTypeUuid if ((!IfSpec || !memcmp(&If->InterfaceId, &cif->If->InterfaceId, sizeof(RPC_SYNTAX_IDENTIFIER))) && UuidEqual(MgrTypeUuid, &cif->MgrTypeUuid, &status)) { list_remove(&cif->entry); + TRACE("unregistering cif %p\n", cif); if (cif->CurrentCalls) { completed = FALSE; + cif->Delete = TRUE; if (WaitForCallsToComplete) cif->CallsCompletedEvent = event = CreateEventW(NULL, FALSE, FALSE, NULL); } diff --git a/dlls/rpcrt4/rpc_server.h b/dlls/rpcrt4/rpc_server.h index eb32be6afc9..f1804d307e7 100644 --- a/dlls/rpcrt4/rpc_server.h +++ b/dlls/rpcrt4/rpc_server.h @@ -73,6 +73,7 @@ typedef struct _RpcServerInterface /* set when unregistering interface to let the caller of * RpcServerUnregisterIf* know that all calls have finished */ HANDLE CallsCompletedEvent; + BOOL Delete; /* delete when the last call finishes */ } RpcServerInterface; void RPCRT4_new_client(RpcConnection* conn);