From bd31e320ddbeddd7d6948839fb5db786b0659b8b Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Thu, 1 Sep 2016 21:44:24 +0200 Subject: [PATCH] schedsvc: Avoid deadlock when scheduler service starts rpcss. Signed-off-by: Sebastian Lackner Signed-off-by: Alexandre Julliard --- dlls/schedsvc/svc_main.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/dlls/schedsvc/svc_main.c b/dlls/schedsvc/svc_main.c index b5593116aea..45496c93e12 100644 --- a/dlls/schedsvc/svc_main.c +++ b/dlls/schedsvc/svc_main.c @@ -175,8 +175,6 @@ void WINAPI ServiceMain(DWORD argc, LPWSTR *argv) { TRACE("starting Task Scheduler Service\n"); - if (RPC_init() != RPC_S_OK) return; - schedsvc_handle = RegisterServiceCtrlHandlerW(scheduleW, schedsvc_handler); if (!schedsvc_handle) { @@ -186,11 +184,15 @@ void WINAPI ServiceMain(DWORD argc, LPWSTR *argv) done_event = CreateEventW(NULL, TRUE, FALSE, NULL); - schedsvc_update_status(SERVICE_RUNNING); + schedsvc_update_status(SERVICE_START_PENDING); - WaitForSingleObject(done_event, INFINITE); + if (RPC_init() == RPC_S_OK) + { + schedsvc_update_status(SERVICE_RUNNING); + WaitForSingleObject(done_event, INFINITE); + RPC_finish(); + } - RPC_finish(); schedsvc_update_status(SERVICE_STOPPED); TRACE("exiting Task Scheduler Service\n");