Browse Source

AThreads: prevent deadlock for event set before waited

Marcus Sackrow 3 years ago
parent
commit
638de87a5a
1 changed files with 2 additions and 0 deletions
  1. 2 0
      rtl/amicommon/athreads.pp

+ 2 - 0
rtl/amicommon/athreads.pp

@@ -1133,6 +1133,7 @@ begin
       {$IFDEF DEBUG_AMIEVENT}
       {$IFDEF DEBUG_AMIEVENT}
       SysDebugLn('AmiEvent: WaitFor Early Destroy');
       SysDebugLn('AmiEvent: WaitFor Early Destroy');
       {$ENDIF}
       {$ENDIF}
+      ReleaseSemaphore(@AmiEvent^.Sem);
       Exit;
       Exit;
     end;
     end;
     if AmiEvent^.IsSet then
     if AmiEvent^.IsSet then
@@ -1143,6 +1144,7 @@ begin
       {$IFDEF DEBUG_AMIEVENT}
       {$IFDEF DEBUG_AMIEVENT}
       SysDebugLn('AmiEvent: WaitFor Early Signaled');
       SysDebugLn('AmiEvent: WaitFor Early Signaled');
       {$ENDIF}
       {$ENDIF}
+      ReleaseSemaphore(@AmiEvent^.Sem);
       Exit;
       Exit;
     end;
     end;
     // signal not set, so we add this call to the waiterlist
     // signal not set, so we add this call to the waiterlist