Browse Source

* WasiRTLEventWaitFor_WaitNotAllowed: treat timeout of 0 as zero wait time,
instead of infinite time, for consistency with WasiRTLEventWaitFor_WaitAllowed
(and other platforms, such as Windows)

Nikolay Nikolov 1 year ago
parent
commit
5de7084d35
1 changed files with 2 additions and 2 deletions
  1. 2 2
      rtl/wasi/systhrd.inc

+ 2 - 2
rtl/wasi/systhrd.inc

@@ -231,12 +231,12 @@ Var
 begin
   IsMain:=GlobalIsMainThread<>0;
   {$IFDEF DEBUGWASMTHREADS}DebugWriteln('WasiRTLEventWaitFor_WaitNotAllowed : waiting (is main: '+intToStr(Ord(IsMain))+')');{$ENDIF}
-  if aTimeoutNs>0 then
+  if aTimeoutNs>=0 then
     EndTime:=GetClockTime+aTimeoutNs
   else
     EndTime:=0;
   Repeat
-    IsTimeOut:=(aTimeoutNs>0) and (GetClockTime>EndTime);
+    IsTimeOut:=(aTimeoutNs>=0) and (GetClockTime>EndTime);
     IsDone:=(aEvent^.Signal=1) or (aEvent^.Destroying) or (Not IsMain and (GetThreadState(GetSelfThread)<>tsRunning));
   Until isTimeOut or IsDone;
   {$IFDEF DEBUGWASMTHREADS}DebugWriteln('WasiRTLEventWaitFor_WaitNotAllowed : done waiting');{$ENDIF}