StandaloneStartup.st
changeset 20592 fe2fe29df676
parent 20587 cdcab9745677
child 20600 222ed6c9364e
child 20668 f8b2b33db5c1
--- a/StandaloneStartup.st	Tue Oct 11 12:32:44 2016 +0200
+++ b/StandaloneStartup.st	Tue Oct 11 12:33:29 2016 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
  COPYRIGHT (c) 2006 by eXept Software AG
               All Rights Reserved
@@ -577,7 +579,7 @@
 
     OperatingSystem isMSDOSlike ifTrue:[
         self verboseInfo:('create mutex...').
-        handleAndLastErrorCode := OperatingSystem createMutexNamed: (self applicationUUID printString).
+        handleAndLastErrorCode := OperatingSystem createMutexNamed:(self applicationUUID printString).
         MutexHandle := handleAndLastErrorCode first.
         lastErrorCode := handleAndLastErrorCode second.
         "/ self assert: lastErrorCode == 0.
@@ -587,8 +589,17 @@
             or:[lastErrorCode == 5 "ERROR_ACCESS_DENIED"]].
 
         self verboseInfo:('alreadyExists = ',alreadyExists printString).
-        alreadyExists ifFalse:[OperatingSystem waitForSingleObject: MutexHandle].
-        ^ alreadyExists
+        alreadyExists ifTrue:[
+            "we do not own the Mutex, so we cannot release it"
+            MutexHandle notNil ifTrue:[
+                OperatingSystem primCloseHandle: MutexHandle.
+                MutexHandle := nil.
+            ].
+        ] ifFalse:[
+            "no need to wait, createMutex sets initialOwner = true"    
+"/            OperatingSystem waitForSingleObject: MutexHandle.
+        ].
+        ^ alreadyExists.
     ].
 
     ^ false.
@@ -641,7 +652,6 @@
 !
 
 releaseApplicationMutex
-
     (MutexHandle notNil and:[OperatingSystem isMSDOSlike]) ifTrue:[
         OperatingSystem releaseMutex: MutexHandle.
         OperatingSystem primCloseHandle: MutexHandle.