Browse Source

* try to unlock mutex before destroying it

git-svn-id: trunk@1186 -
florian 20 years ago
parent
commit
a897adf6cc
1 changed files with 5 additions and 0 deletions
  1. 5 0
      rtl/unix/cthreads.pp

+ 5 - 0
rtl/unix/cthreads.pp

@@ -340,6 +340,11 @@ Type  PINTRTLEvent = ^TINTRTLEvent;
 
     procedure CDoneCriticalSection(var CS);
       begin
+         { unlock as long as unlocking works to unlock it if it is recursive
+           some Delphi code might call this function with a locked mutex      }
+         while pthread_mutex_unlock(@CS)=0 do
+           ;
+
          if pthread_mutex_destroy(@CS) <> 0 then
            runerror(6);
       end;