diff --git a/src/client/toks_client_acquire.c b/src/client/toks_client_acquire.c index 3048ffc..c50b66a 100644 --- a/src/client/toks_client_acquire.c +++ b/src/client/toks_client_acquire.c @@ -33,6 +33,7 @@ static int32_t toks_client_cancel(void * hport) int32_t toks_client_acquire(struct toks_driver_ctx * dctx) { int32_t status; + int32_t estatus; void * hport; struct _nt_tty_sync_msg msg; struct _nt_port_keys * keys; @@ -95,32 +96,36 @@ int32_t toks_client_acquire(struct toks_driver_ctx * dctx) hduo[0] = msg.data.syncinfo.hevent; hduo[1] = toks_get_driver_hserver(dctx); - ntapi->zw_wait_for_multiple_objects( + status = ntapi->zw_wait_for_multiple_objects( 2,hduo, NT_WAIT_ANY, NT_SYNC_NON_ALERTABLE, &timeout); - status = ntapi->zw_query_event( + estatus = ntapi->zw_query_event( msg.data.syncinfo.hevent, NT_EVENT_BASIC_INFORMATION, &syncebi,sizeof(syncebi), &(size_t){0}); - if ((status == NT_STATUS_SUCCESS) && !syncebi.signal_state) { - return NT_STATUS_SYSTEM_PROCESS_TERMINATED; + if ((estatus == NT_STATUS_SUCCESS) && syncebi.signal_state) + status = NT_STATUS_SUCCESS; - } else if (status == NT_STATUS_SUCCESS) { - (void)0; + switch (status) { + case NT_STATUS_SUCCESS: + break; - } else { - switch (toks_client_cancel(hport)) { - case NT_STATUS_NOT_FOUND: - break; + case NT_STATUS_TIMEOUT: + switch (toks_client_cancel(hport)) { + case NT_STATUS_NOT_FOUND: + break; - default: - return status; - } + default: + return status; + } + + default: + return NT_STATUS_SYSTEM_PROCESS_TERMINATED; } break;