From d34088be2d0fcac4274512f7c0509ad3a873e892 Mon Sep 17 00:00:00 2001 From: midipix Date: Sat, 7 May 2016 18:09:19 -0400 Subject: daemon init routine: internal client init: take a more robust code path. Following this change, the temporary internal client thread is created only after the daemon dedicated thread has signaled the daemon-is-ready event. --- src/daemon/ntapi_dsr_init.c | 14 ++++++++++++++ src/daemon/ntapi_dsr_internal_connection.c | 10 ---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/daemon/ntapi_dsr_init.c b/src/daemon/ntapi_dsr_init.c index 91224c7..be72502 100644 --- a/src/daemon/ntapi_dsr_init.c +++ b/src/daemon/ntapi_dsr_init.c @@ -72,6 +72,20 @@ int32_t __stdcall __ntapi_dsr_init(nt_daemon_params * params) params->hthread_daemon_loop = tparams.hthread; if (status) return status; + + /* wait for the server to be ready */ + timeout.quad = NT_DSR_INIT_MAX_WAIT; + + if ((status = __ntapi->zw_wait_for_single_object( + params->hevent_daemon_ready, + 0,&timeout))) { + __ntapi->zw_terminate_thread( + tparams.hthread, + status); + return status; + } + + /* daemon dedicated thread: actual stack size */ params->stack_size_commit = tparams.stack_size_commit; params->stack_size_reserve = tparams.stack_size_reserve; diff --git a/src/daemon/ntapi_dsr_internal_connection.c b/src/daemon/ntapi_dsr_internal_connection.c index 5d8ee09..80c85f4 100644 --- a/src/daemon/ntapi_dsr_internal_connection.c +++ b/src/daemon/ntapi_dsr_internal_connection.c @@ -101,16 +101,6 @@ int32_t __stdcall __ntapi_dsr_internal_client_connect(nt_daemon_params * params) oa.sec_desc = (nt_security_descriptor *)0; oa.sec_qos = &sqos; - /* wait for the server to be ready */ - timeout.quad = NT_DSR_INIT_MAX_WAIT; - - if ((*pstatus = __ntapi->zw_wait_for_single_object( - params->hevent_daemon_ready, - 0,&timeout))) - __ntapi->zw_terminate_thread( - NT_CURRENT_THREAD_HANDLE, - *pstatus); - /* establish internal connection */ *pstatus = __ntapi->zw_connect_port( ¶ms->hport_internal_client, -- cgit v1.2.3