summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2020-12-03 22:12:17 +0000
committermidipix <writeonce@midipix.org>2020-12-04 13:24:16 +0000
commit4a5679eb2c3e36feb5af04b717949e41ec4b5d91 (patch)
treebef0155b5c78f9b56cfdfbe8f13daef69b97150a
parentcc20b3d7478519676a573055015528d7a6c47d45 (diff)
downloadntapi-4a5679eb2c3e36feb5af04b717949e41ec4b5d91.tar.bz2
ntapi-4a5679eb2c3e36feb5af04b717949e41ec4b5d91.tar.xz
__ntapi_tt_fork_v1(): obtain atomic lock via loop as needed.
-rw-r--r--src/process/ntapi_tt_fork_v1.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/process/ntapi_tt_fork_v1.c b/src/process/ntapi_tt_fork_v1.c
index eeee49b..74e0b7e 100644
--- a/src/process/ntapi_tt_fork_v1.c
+++ b/src/process/ntapi_tt_fork_v1.c
@@ -166,15 +166,20 @@ intptr_t __fastcall __ntapi_tt_fork_v1(
timeout.quad = (-1) * 10 * 1000 * __NT_FORK_CHILD_WAIT_MILLISEC;
htty_connected = 0;
- if (at_locked_cas(&__internals->hlock,0,1))
- return (intptr_t)(-1);
+ while (at_locked_cas(&__internals->hlock,0,1))
+ __ntapi->zw_delay_execution(
+ NT_SYNC_NON_ALERTABLE,
+ &(nt_timeout){{0,0}});
- if (hport_session && *hport_session)
+ if (hport_session && *hport_session) {
if (__ntapi_tt_create_inheritable_event(
&htty_connected,
NT_NOTIFICATION_EVENT,
- NT_EVENT_NOT_SIGNALED))
+ NT_EVENT_NOT_SIGNALED)) {
+ at_store(&__internals->hlock,0);
return (intptr_t)(-1);
+ }
+ }
pid = __tt_fork_v1();