From 731535949b42aa1a333f84ede427f44bc903b1ab Mon Sep 17 00:00:00 2001 From: midipix Date: Jun 17 2020 23:03:24 +0000 Subject: toks_client_acquire(): properly handle a server abort during a wait operation. --- diff --git a/src/client/toks_client_acquire.c b/src/client/toks_client_acquire.c index 32c0835..e7d61ac 100644 --- a/src/client/toks_client_acquire.c +++ b/src/client/toks_client_acquire.c @@ -38,8 +38,10 @@ int32_t toks_client_acquire(struct toks_driver_ctx * dctx) struct _nt_port_keys * keys; int64_t millisecs; nt_timeout timeout; + nt_ebi syncebi; const char * refstr; size_t reflen; + void * hduo[2]; hport = toks_get_driver_hservice(dctx); keys = toks_get_driver_keys(dctx); @@ -90,12 +92,28 @@ int32_t toks_client_acquire(struct toks_driver_ctx * dctx) break; case NT_STATUS_PENDING: - status = ntapi->zw_wait_for_single_object( - msg.data.syncinfo.hevent, + hduo[0] = msg.data.syncinfo.hevent; + hduo[1] = toks_get_driver_hserver(dctx); + + ntapi->zw_wait_for_multiple_objects( + 2,hduo, + NT_WAIT_ANY, NT_SYNC_NON_ALERTABLE, &timeout); - if (status != NT_STATUS_SUCCESS) { + status = 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; + + } else if (status == NT_STATUS_SUCCESS) { + (void)0; + + } else { switch (toks_client_cancel(hport)) { case NT_STATUS_NOT_FOUND: break;