summaryrefslogtreecommitdiffhomepage
path: root/src
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
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')
-rw-r--r--src/daemon/ntapi_dsr_init.c14
-rw-r--r--src/daemon/ntapi_dsr_internal_connection.c10
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(
&params->hport_internal_client,