RecursionLock.st
changeset 20734 52db398ec2e0
parent 20385 f8655a0e0503
child 21024 8734987eb5c7
child 21191 3e3647a45a01
--- a/RecursionLock.st	Thu Nov 03 10:16:11 2016 +0100
+++ b/RecursionLock.st	Thu Nov 03 10:20:55 2016 +0100
@@ -172,7 +172,9 @@
      Attention: if asked without some global lock (blockedInterrupts),
      the returned value may be outdated right away."
 
-    ^ process notNil and:[Processor activeProcess ~~ process]
+    |p|
+    
+    ^ (p := process) notNil and:[Processor activeProcess ~~ p and:[p isDead not]]
 ! !
 
 !RecursionLock methodsFor:'signaling'!
@@ -223,8 +225,9 @@
     wasBlocked := OperatingSystem blockInterrupts.
     [
         (process notNil and:[process isDead]) ifTrue:[
+            process := nil. 
             'RecursionLock [warning]: cleanup lock from dead process' infoPrintCR.
-            process := nil. sema signal.
+            sema signal.
         ].
         gotSema := sema wait.
         process := active.
@@ -285,8 +288,9 @@
     wasBlocked := OperatingSystem blockInterrupts.
     [
         (process notNil and:[process isDead]) ifTrue:[
+            process := nil. 
             'RecursionLock [warning]: cleanup lock from dead process' infoPrintCR.
-            process := nil. sema signal.
+            sema signal.
         ].
         gotSema := sema waitWithTimeoutMs:timeoutMs.
         gotSema notNil ifTrue:[
@@ -332,8 +336,10 @@
 
     wasBlocked := OperatingSystem blockInterrupts.
     (process notNil and:[process isDead]) ifTrue:[
-        'RecursionLock [warning]: cleanup lock from dead process' infoPrintCR.
-        process := nil. sema signal.
+        "/ a process which had the lock died without a chance to release it (i.e. it was hard terminated)
+        process := nil. 
+        'RecursionLock [info]: cleanup leftover lock from dead process' infoPrintCR.
+        sema signal.
     ].
     sema wait.
     process := active.