mutex fix
authorfm
Mon, 21 Jul 2008 18:19:15 +0200
changeset 11092 a05bd545f00d
parent 11091 b64647b51eca
child 11093 0af5422c9467
mutex fix
Win32OperatingSystem.st
--- a/Win32OperatingSystem.st	Mon Jul 21 17:53:20 2008 +0200
+++ b/Win32OperatingSystem.st	Mon Jul 21 18:19:15 2008 +0200
@@ -6426,10 +6426,11 @@
 
     |handle lastErrorCode|
 
-    self primSetLastError: 0.               
+    self primSetLastError: 0.   
+    self primGetLastError.
     handle := self primCreateMutex:nil initialOwner: true name: name.
     lastErrorCode := self primGetLastError.
-    self assert: lastErrorCode == 0.
+"/    self assert: lastErrorCode == 0.
     lastErrorCode == 5 "ERROR_ACCESS_DENIED" ifTrue:[Transcript showCR: 'Mutex not accesible (GetLastError = ERROR_ACCESS_DENIED)'.].
     lastErrorCode == 183 "ERROR_ALREADY_EXISTS" ifTrue:[Transcript showCR: 'Mutex already exists (GetLastError = ERROR_ALREADY_EXISTS)'.].
     (handle isNil or:[handle address ~~ 0]) ifFalse:[
@@ -6451,8 +6452,10 @@
     handleAndLastErrorCode := self createMutexNamed: name.
     handle := handleAndLastErrorCode first.
     lastErrorCode := handleAndLastErrorCode second.
-    ^ (handle isNil and:[lastErrorCode == 183 "ERROR_ALREADY_EXISTS"]) 
-        or:[ lastErrorCode == 5 "ERROR_ACCESS_DENIED"]
+"/    self assert: lastErrorCode == 0.
+    ^ handle isNil 
+        or:[lastErrorCode == 183 "ERROR_ALREADY_EXISTS" 
+            or:[ lastErrorCode == 5 "ERROR_ACCESS_DENIED"]]
 !
 
 openMutexNamed: name
@@ -6558,8 +6561,9 @@
 
     handleAndLastErrorCode := self createMutexNamed: '8906f5e0-54ed-11dd-9da4-001558137da0'.
     handle := handleAndLastErrorCode first.
-    (handle isNil or:[handle address == 0]) ifTrue:[^ self].
+    handle isNil ifTrue:[^ self].
     lastErrorCode := handleAndLastErrorCode second.
+    self assert: lastErrorCode == 0.
     alreadyExists := (lastErrorCode == 5 "ERROR_ACCESS_DENIED" or:[ lastErrorCode == 183 "ERROR_ALREADY_EXISTS"]).
     alreadyExists ifTrue:[
         Transcript showCR: 'Mutex already exists!!'.
@@ -6581,7 +6585,7 @@
 
     |result|
 
-    result := self primWaitForSingleObject: handle milliseconds: 10.
+    result := self primWaitForSingleObject: handle milliseconds: 500.
     ^ result
 ! !
 
@@ -15597,7 +15601,7 @@
 !Win32OperatingSystem class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.339 2008-07-21 15:53:20 fm Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.340 2008-07-21 16:19:15 fm Exp $'
 ! !
 
 Win32OperatingSystem initialize!