diff options
author | midipix <writeonce@midipix.org> | 2016-05-07 18:09:19 -0400 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2016-05-07 18:09:19 -0400 |
commit | d34088be2d0fcac4274512f7c0509ad3a873e892 (patch) | |
tree | 5b354e7158ec507d85ae956bc1a5be451ecebd8f /src/daemon | |
parent | b354be64f194e4fdb737602d1701995185d80d62 (diff) | |
download | ntapi-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')
-rw-r--r-- | src/daemon/ntapi_dsr_init.c | 14 | ||||
-rw-r--r-- | 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, |