summaryrefslogtreecommitdiffhomepage
path: root/src/daemon/ntapi_dsr_init.c
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-05-07 18:09:19 -0400
committermidipix <writeonce@midipix.org>2016-05-07 18:09:19 -0400
commitd34088be2d0fcac4274512f7c0509ad3a873e892 (patch)
tree5b354e7158ec507d85ae956bc1a5be451ecebd8f /src/daemon/ntapi_dsr_init.c
parentb354be64f194e4fdb737602d1701995185d80d62 (diff)
downloadntapi-d34088be2d0fcac4274512f7c0509ad3a873e892.tar.bz2
ntapi-d34088be2d0fcac4274512f7c0509ad3a873e892.tar.xz
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.
Diffstat (limited to 'src/daemon/ntapi_dsr_init.c')
-rw-r--r--src/daemon/ntapi_dsr_init.c14
1 files changed, 14 insertions, 0 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;