[7/7] services: Remove synchronization for CloseThreadpoolCleanupGroupMembers.
Sebastian Lackner
sebastian at fds-team.de
Sat Aug 20 14:24:52 CDT 2016
Signed-off-by: Sebastian Lackner <sebastian at fds-team.de>
---
With all the previous changes it is now safe to remove the synchronization. In
addition, this patch also adds a group cancel callback to release any process
references which would otherwise be leaked.
programs/services/rpc.c | 28 ++++++++--------------------
1 file changed, 8 insertions(+), 20 deletions(-)
diff --git a/programs/services/rpc.c b/programs/services/rpc.c
index 688e4a0..bd6af95 100644
--- a/programs/services/rpc.c
+++ b/programs/services/rpc.c
@@ -85,30 +85,22 @@ struct sc_lock
struct scmdatabase *db;
};
-static CRITICAL_SECTION shutdown_cs;
-static CRITICAL_SECTION_DEBUG critsect_debug =
-{
- 0, 0, &shutdown_cs,
- { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
- 0, 0, { (DWORD_PTR)(__FILE__ ": shutdown_cs") }
-};
-static CRITICAL_SECTION shutdown_cs = { &critsect_debug, -1, 0, 0, 0, 0 };
-static BOOL service_shutdown;
-
static PTP_CLEANUP_GROUP cleanup_group;
HANDLE exit_event;
+static void CALLBACK group_cancel_callback(void *object, void *userdata)
+{
+ struct process_entry *process = object;
+ release_process(process);
+}
+
static void CALLBACK terminate_callback(TP_CALLBACK_INSTANCE *instance, void *context,
TP_WAIT *wait, TP_WAIT_RESULT result)
{
struct process_entry *process = context;
if (result == WAIT_TIMEOUT) process_terminate(process);
release_process(process);
-
- /* synchronize with CloseThreadpoolCleanupGroupMembers */
- EnterCriticalSection(&shutdown_cs);
- if (!service_shutdown) CloseThreadpoolWait(wait);
- LeaveCriticalSection(&shutdown_cs);
+ CloseThreadpoolWait(wait);
}
static void terminate_after_timeout(struct process_entry *process, DWORD timeout)
@@ -121,6 +113,7 @@ static void terminate_after_timeout(struct process_entry *process, DWORD timeout
memset(&environment, 0, sizeof(environment));
environment.Version = 1;
environment.CleanupGroup = cleanup_group;
+ environment.CleanupGroupCancelCallback = group_cancel_callback;
timestamp.QuadPart = (ULONGLONG)timeout * -10000;
ft.dwLowDateTime = timestamp.u.LowPart;
@@ -1914,11 +1907,6 @@ void RPC_Stop(void)
RpcMgmtStopServerListening(NULL);
RpcServerUnregisterIf(svcctl_v2_0_s_ifspec, NULL, TRUE);
- /* synchronize with CloseThreadpoolWait */
- EnterCriticalSection(&shutdown_cs);
- service_shutdown = TRUE;
- LeaveCriticalSection(&shutdown_cs);
-
CloseThreadpoolCleanupGroupMembers(cleanup_group, TRUE, NULL);
CloseThreadpoolCleanupGroup(cleanup_group);
CloseHandle(exit_event);
--
2.9.0
More information about the wine-patches
mailing list