[corlib] EventWaitHandle from referencesource
authorMarek Safar <marek.safar@gmail.com>
Fri, 3 Jun 2016 13:18:42 +0000 (15:18 +0200)
committerMarek Safar <marek.safar@gmail.com>
Mon, 22 Aug 2016 21:20:00 +0000 (23:20 +0200)
15 files changed:
mcs/class/corlib/System.IO/Path.cs
mcs/class/corlib/System.Runtime.InteropServices/SafeHandle.cs
mcs/class/corlib/System.Security.AccessControl/NativeObjectSecurity.cs
mcs/class/corlib/System.Threading/EventWaitHandle.cs [deleted file]
mcs/class/corlib/System.Threading/NativeEventCalls.cs
mcs/class/corlib/System/Environment.cs
mcs/class/corlib/Test/System.Threading/EventWaitHandleTest.cs
mcs/class/corlib/corlib.dll.sources
mcs/class/referencesource/System/sys/system/IO/ports/InternalResources.cs
mcs/class/referencesource/System/sys/system/threading/semaphore.cs
mcs/class/referencesource/mscorlib/system/threading/eventwaithandle.cs
mono/metadata/appdomain.c
mono/metadata/icall-def.h
mono/metadata/threads-types.h
mono/metadata/threads.c

index 09ea4405953409657b36364b9a504f94e3487064..5216dd08df25ae7d685463bd9ee62ac61d05f125 100644 (file)
@@ -885,5 +885,7 @@ namespace System.IO {
                                return DirectorySeparatorStr;
                        }
                }
+
+               internal const int MAX_PATH = 260;  // From WinDef.h
        }
 }
index b5b59a1ae81ffb3f37822fd47ba5619f08d7469a..a01d526ff2588d5e1d32eea908836061f47b91c2 100644 (file)
@@ -122,7 +122,7 @@ namespace System.Runtime.InteropServices
                                        old_state = _state;
 
                                        if ((old_state & (int) State.Closed) != 0)
-                                               throw new ObjectDisposedException ("handle");
+                                               throw new ObjectDisposedException (null, "Safe handle has been closed");
 
                                        new_state = old_state + RefCount_One;
                                } while (Interlocked.CompareExchange (ref _state, new_state, old_state) != old_state);
@@ -198,7 +198,7 @@ namespace System.Runtime.InteropServices
                                         * hitting zero though -- that can happen if SetHandleAsInvalid is
                                         * used). */
                                        if ((old_state & RefCount_Mask) == 0)
-                                               throw new ObjectDisposedException ("handle");
+                                               throw new ObjectDisposedException (null, "Safe handle has been closed");
 
                                        if ((old_state & RefCount_Mask) != RefCount_One)
                                                perform_release = false;
index 7e83a6cacf0a297bccf6973c93a0762b405fe84f..b951a8141d5d38927a3798202cdfae98f9751474 100644 (file)
@@ -129,6 +129,11 @@ namespace System.Security.AccessControl
                {
                        Persist (name, includeSections, null);
                }
+
+               internal void Persist (SafeHandle handle)
+               {
+                       PersistModifications (handle);
+               }
                
                internal void PersistModifications (SafeHandle handle)
                {
diff --git a/mcs/class/corlib/System.Threading/EventWaitHandle.cs b/mcs/class/corlib/System.Threading/EventWaitHandle.cs
deleted file mode 100644 (file)
index 0594eb1..0000000
+++ /dev/null
@@ -1,235 +0,0 @@
-//
-// System.Threading.EventWaitHandle.cs
-//
-// Author:
-//     Dick Porter (dick@ximian.com)
-//
-// (C) Ximian, Inc.    (http://www.ximian.com)
-// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System.IO;
-using System.Runtime.InteropServices;
-using System.Security.AccessControl;
-
-namespace System.Threading
-{
-       [ComVisible (true)]
-       public class EventWaitHandle : WaitHandle
-       {
-               private EventWaitHandle (IntPtr handle)
-               {
-                       Handle = handle;
-               }
-
-               static bool IsManualReset (EventResetMode mode)
-               {
-                       if ((mode < EventResetMode.AutoReset) || (mode > EventResetMode.ManualReset))
-                               throw new ArgumentException ("mode");
-                       return (mode == EventResetMode.ManualReset);
-               }
-               
-               public EventWaitHandle (bool initialState, EventResetMode mode)
-               {
-                       bool created;
-                       bool manual = IsManualReset (mode);
-                       Handle = NativeEventCalls.CreateEvent_internal (manual, initialState, null, out created);
-               }
-               
-#if !MOBILE
-               
-               public EventWaitHandle (bool initialState, EventResetMode mode,
-                                       string name)
-               {
-                       bool created;
-                       bool manual = IsManualReset (mode);
-                       Handle = NativeEventCalls.CreateEvent_internal (manual, initialState, name, out created);
-               }
-               
-               public EventWaitHandle (bool initialState, EventResetMode mode,
-                                       string name, out bool createdNew)
-               {
-                       bool manual = IsManualReset (mode);
-                       Handle = NativeEventCalls.CreateEvent_internal (manual, initialState, name, out createdNew);
-               }
-
-
-               [MonoTODO ("Use access control in CreateEvent_internal")]
-               public EventWaitHandle (bool initialState, EventResetMode mode,
-                                       string name, out bool createdNew,
-                                       EventWaitHandleSecurity eventSecurity)
-               {
-                       bool manual = IsManualReset (mode);
-                       Handle = NativeEventCalls.CreateEvent_internal (manual, initialState, name, out createdNew);
-               }
-               
-               public EventWaitHandleSecurity GetAccessControl ()
-               {
-                       return new EventWaitHandleSecurity (SafeWaitHandle,
-                                                           AccessControlSections.Owner |
-                                                           AccessControlSections.Group |
-                                                           AccessControlSections.Access);
-
-               }
-
-               public static EventWaitHandle OpenExisting (string name)
-               {
-                       return(OpenExisting (name, EventWaitHandleRights.Synchronize | EventWaitHandleRights.Modify));
-               }
-
-               public static EventWaitHandle OpenExisting (string name, EventWaitHandleRights rights)
-               {
-                       if (name == null) {
-                               throw new ArgumentNullException ("name");
-                       }
-                       if ((name.Length == 0) ||
-                           (name.Length > 260)) {
-                               throw new ArgumentException ("name", Locale.GetText ("Invalid length [1-260]."));
-                       }
-                       
-                       MonoIOError error;
-                       IntPtr handle = NativeEventCalls.OpenEvent_internal (name, rights, out error);
-                       if (handle == (IntPtr)null) {
-                               if (error == MonoIOError.ERROR_FILE_NOT_FOUND) {
-                                       throw new WaitHandleCannotBeOpenedException (Locale.GetText ("Named Event handle does not exist: ") + name);
-                               } else if (error == MonoIOError.ERROR_ACCESS_DENIED) {
-                                       throw new UnauthorizedAccessException ();
-                               } else {
-                                       throw new IOException (Locale.GetText ("Win32 IO error: ") + error.ToString ());
-                               }
-                       }
-                       
-                       return(new EventWaitHandle (handle));
-               }
-
-               public static bool TryOpenExisting (string name, out EventWaitHandle result)
-               {
-                       return TryOpenExisting (
-                               name, EventWaitHandleRights.Synchronize | EventWaitHandleRights.Modify, out result);
-               }
-
-               public static bool TryOpenExisting (string name, EventWaitHandleRights rights,
-                                                   out EventWaitHandle result)
-               {
-                       if (name == null) {
-                               throw new ArgumentNullException ("name");
-                       }
-                       if ((name.Length == 0) || (name.Length > 260)) {
-                               throw new ArgumentException ("name", Locale.GetText ("Invalid length [1-260]."));
-                       }
-                       
-                       MonoIOError error;
-                       IntPtr handle = NativeEventCalls.OpenEvent_internal (name, rights, out error);
-                       if (handle == (IntPtr)null) {
-                               result = null;
-                               return false;
-                       }
-
-                       result = new EventWaitHandle (handle);
-                       return true;
-               }
-#else
-               public EventWaitHandle (bool initialState, EventResetMode mode, string name)
-               {
-                       throw new NotSupportedException ();
-               }
-               
-               public EventWaitHandle (bool initialState, EventResetMode mode,
-                                       string name, out bool createdNew)
-               {
-                       throw new NotSupportedException ();
-               }
-               
-               
-               public EventWaitHandle (bool initialState, EventResetMode mode,
-                                       string name, out bool createdNew,
-                                       EventWaitHandleSecurity eventSecurity)
-               {
-                       throw new NotSupportedException ();
-               }
-
-               public static EventWaitHandle OpenExisting (string name)
-               {
-                       throw new NotSupportedException (); 
-               }
-
-               public static EventWaitHandle OpenExisting (string name, EventWaitHandleRights rights)
-               {
-                       throw new NotSupportedException (); 
-               }
-
-               public static bool TryOpenExisting (string name, out EventWaitHandle result)
-               {
-                       throw new NotSupportedException (); 
-               }
-
-               public static bool TryOpenExisting (string name, EventWaitHandleRights rights,
-                                                   out EventWaitHandle result)
-               {
-                       throw new NotSupportedException (); 
-               }
-#endif
-
-               public bool Reset ()
-               {
-                       /* This needs locking since another thread could dispose the handle */
-                       lock (this) {
-                               CheckDisposed ();
-                       
-                               return NativeEventCalls.ResetEvent (SafeWaitHandle);
-                       }
-               }
-               
-               public bool Set ()
-               {
-                       lock (this) {
-                               CheckDisposed ();
-                       
-                               return NativeEventCalls.SetEvent (SafeWaitHandle);
-                       }
-               }
-
-               internal void CheckDisposed ()
-               {
-                       if (disposed)
-                               throw new ObjectDisposedException (GetType ().FullName);
-               }
-
-               bool disposed;
-               protected override void Dispose(bool explicitDisposing)
-               {
-                       base.Dispose (explicitDisposing);
-                       disposed = true;
-               }
-
-#if !MOBILE
-               public void SetAccessControl (EventWaitHandleSecurity eventSecurity)
-               {
-                       if (null == eventSecurity)
-                               throw new ArgumentNullException ("eventSecurity");
-                               
-                       eventSecurity.PersistModifications (SafeWaitHandle);
-
-               }
-#endif
-       }
-}
index b0320579bfa227ec3a8058fe50ab22774d6fbf6d..fc5a9f59babe887360a7eccdc6eadb088e285946 100644 (file)
@@ -45,7 +45,7 @@ namespace System.Threading
        internal static class NativeEventCalls
        {
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
-               public static extern IntPtr CreateEvent_internal(bool manual,bool initial,string name, out bool created);
+               public static extern IntPtr CreateEvent_internal (bool manual, bool initial, string name, out int errorCode);
 
                public static bool SetEvent (SafeWaitHandle handle)
                {
@@ -82,7 +82,7 @@ namespace System.Threading
 
 #if !MOBILE
                [MethodImplAttribute (MethodImplOptions.InternalCall)]
-               public static extern IntPtr OpenEvent_internal (string name, EventWaitHandleRights rights, out MonoIOError error);
+               public static extern IntPtr OpenEvent_internal (string name, EventWaitHandleRights rights, out int errorCode);
 #endif
        }
 }
index acaab9bbeca33a14f5fe127c14e2c0ef9b12886b..88dff3e3527d2f8e2763e19db2ceb0f85f61d7c0 100644 (file)
@@ -57,7 +57,7 @@ namespace System {
                 * of icalls, do not require an increment.
                 */
 #pragma warning disable 169
-               private const int mono_corlib_version = 152;
+               private const int mono_corlib_version = 153;
 #pragma warning restore 169
 
                [ComVisible (true)]
index c0e50b9cb89eac2814730d6ad97bcb0e61b3d79c..005a9d86887a3e97952f5ac36f4d7557d8c10883 100644 (file)
@@ -43,6 +43,18 @@ namespace MonoTests.System.Threading {
                {
                        new EventWaitHandle (true, (EventResetMode) Int32.MinValue);
                }
+
+               [Test]
+               public void Disposed_Set ()
+               {
+                       var ewh = new EventWaitHandle (false, EventResetMode.ManualReset);
+                       ewh.Dispose();
+                       try {
+                               ewh.Set();
+                               Assert.Fail ();
+                       } catch (ObjectDisposedException) {
+                       }
+               }
        }
 }
 
index 8ab200076af0584776afe44df7b5a961942620e0..20922c7796096da1893e39c5c88fa1f11b8d0017 100644 (file)
@@ -849,7 +849,6 @@ System.Text/EncodingHelper.cs
 System.Text/NormalizationForm.cs
 System.Text/Latin1Encoding.cs
 System.Threading/CompressedStack.cs
-System.Threading/EventWaitHandle.cs
 System.Threading/HostExecutionContext.cs
 System.Threading/HostExecutionContextManager.cs
 System.Threading/Interlocked.cs
@@ -1575,6 +1574,7 @@ ReferenceSources/PathInternal.cs
 ../referencesource/mscorlib/system/threading/CancellationTokenSource.cs
 ../referencesource/mscorlib/system/threading/CountdownEvent.cs
 ../referencesource/mscorlib/system/threading/eventresetmode.cs
+../referencesource/mscorlib/system/threading/eventwaithandle.cs
 ../referencesource/mscorlib/system/threading/executioncontext.cs
 ../referencesource/mscorlib/system/threading/LazyInitializer.cs
 ../referencesource/mscorlib/system/threading/lockrecursionexception.cs
index 973773d29467b190eb5bc811cf07ab5f8f843ee4..5a68cc4744f5d95dba788357ea89a9043a963fab 100644 (file)
@@ -78,6 +78,7 @@ namespace System.IO.Ports
         }
 #endif
 
+#if !MONO
 #if FEATURE_NETCORE
         [SecuritySafeCritical]
 #endif
@@ -95,6 +96,7 @@ namespace System.IO.Ports
             int errorCode = Marshal.GetLastWin32Error();
             WinIOError(errorCode, str);
         }
+#endif
         
         // After calling GetLastWin32Error(), it clears the last error field,
         // so you must save the HResult and pass it to this method.  This method
index 360a55fa534abd5beff1d34fff8ac7d2a233e1c9..eae169c364f07c1c70e52b8a7aac444dadda66b0 100644 (file)
@@ -87,7 +87,11 @@ namespace System.Threading
                 if(null != name && 0 != name.Length && NativeMethods.ERROR_INVALID_HANDLE == errorCode)
                     throw new WaitHandleCannotBeOpenedException(SR.GetString(SR.WaitHandleCannotBeOpenedException_InvalidHandle,name));
                
+#if MONO
+                InternalResources.WinIOError(errorCode, "");
+#else
                 InternalResources.WinIOError();
+#endif
             }
             this.SafeWaitHandle = myHandle;
         }
@@ -161,7 +165,12 @@ namespace System.Threading
             {
                 if(null != name && 0 != name.Length && NativeMethods.ERROR_INVALID_HANDLE == errorCode)
                     throw new WaitHandleCannotBeOpenedException(SR.GetString(SR.WaitHandleCannotBeOpenedException_InvalidHandle,name));
+
+#if MONO
+                InternalResources.WinIOError(errorCode, "");
+#else
                 InternalResources.WinIOError();
+#endif
             }
             createdNew = errorCode != NativeMethods.ERROR_ALREADY_EXISTS;
             this.SafeWaitHandle = myHandle;
@@ -310,7 +319,11 @@ namespace System.Threading
                 if (null != name && 0 != name.Length && NativeMethods.ERROR_INVALID_HANDLE == errorCode)
                     return OpenExistingResult.NameInvalid;
                 //this is for passed through NativeMethods Errors
+#if MONO
+                InternalResources.WinIOError(errorCode, "");
+#else
                 InternalResources.WinIOError();
+#endif
             }
             result = new Semaphore(myHandle);
             return OpenExistingResult.Success;
index 08426b232735ae20e30bc235cfb014d7bee30992..cf9bdf17b1b19f95123dc8b0e424c6d3c2aea8ce 100644 (file)
@@ -16,6 +16,7 @@
 =============================================================================*/
 
 
+#if !MOBILE
 #if !FEATURE_MACL
 namespace System.Security.AccessControl
 {
@@ -27,6 +28,7 @@ namespace System.Security.AccessControl
     }
 }
 #endif
+#endif
 
 namespace System.Threading
 {
@@ -63,13 +65,24 @@ namespace System.Threading
             Contract.EndContractBlock();
             
             SafeWaitHandle _handle = null;
+#if MONO
+            int errorCode;
+#endif
             switch(mode)
             {
                 case EventResetMode.ManualReset:
+#if MONO
+                    _handle = new SafeWaitHandle (NativeEventCalls.CreateEvent_internal (true, initialState, name, out errorCode), true);
+#else
                     _handle = Win32Native.CreateEvent(null, true, initialState, name);
+#endif
                     break;
                 case EventResetMode.AutoReset:
+#if MONO
+                    _handle = new SafeWaitHandle (NativeEventCalls.CreateEvent_internal (false, initialState, name, out errorCode), true);
+#else
                     _handle = Win32Native.CreateEvent(null, false, initialState, name);
+#endif
                     break;
 
                 default:
@@ -78,7 +91,9 @@ namespace System.Threading
                 
             if (_handle.IsInvalid)
             {
+#if !MONO
                 int errorCode = Marshal.GetLastWin32Error();
+#endif
             
                 _handle.SetHandleAsInvalid();
                 if(null != name && 0 != name.Length && Win32Native.ERROR_INVALID_HANDLE == errorCode)
@@ -108,6 +123,7 @@ namespace System.Threading
             }
             Contract.EndContractBlock();
             Win32Native.SECURITY_ATTRIBUTES secAttrs = null;
+#if !MONO
 #if FEATURE_MACL
             // For ACL's, get the security descriptor from the EventWaitHandleSecurity.
             if (eventSecurity != null) {
@@ -119,6 +135,7 @@ namespace System.Threading
                 Buffer.Memcpy(pSecDescriptor, 0, sd, 0, sd.Length);
                 secAttrs.pSecurityDescriptor = pSecDescriptor;
             }
+#endif
 #endif
 
             SafeWaitHandle _handle = null;
@@ -136,8 +153,13 @@ namespace System.Threading
                     throw new ArgumentException(Environment.GetResourceString("Argument_InvalidFlag",name));
             };
 
+#if MONO
+            int errorCode;
+            _handle = new SafeWaitHandle (NativeEventCalls.CreateEvent_internal (isManualReset, initialState, name, out errorCode), true);
+#else
             _handle = Win32Native.CreateEvent(secAttrs, isManualReset, initialState, name);
             int errorCode = Marshal.GetLastWin32Error();
+#endif
 
             if (_handle.IsInvalid)
             {
@@ -239,15 +261,26 @@ namespace System.Threading
 
             result = null;
 
+#if MOBILE
+            throw new NotSupportedException ();
+#else
+
+#if MONO
+            int errorCode;
+            var myHandle = new SafeWaitHandle (NativeEventCalls.OpenEvent_internal (name, rights, out errorCode), true);
+#else
 #if FEATURE_MACL
             SafeWaitHandle myHandle = Win32Native.OpenEvent((int) rights, false, name);
 #else
             SafeWaitHandle myHandle = Win32Native.OpenEvent(Win32Native.EVENT_MODIFY_STATE | Win32Native.SYNCHRONIZE, false, name);
+#endif
 #endif
             
             if (myHandle.IsInvalid)
             {
+#if !MONO
                 int errorCode = Marshal.GetLastWin32Error();
+#endif
 
                 if(Win32Native.ERROR_FILE_NOT_FOUND == errorCode || Win32Native.ERROR_INVALID_NAME == errorCode)
                     return OpenExistingResult.NameNotFound;
@@ -260,33 +293,52 @@ namespace System.Threading
             }
             result = new EventWaitHandle(myHandle);
             return OpenExistingResult.Success;
+#endif
         }
         [System.Security.SecuritySafeCritical]  // auto-generated
         public bool Reset()
         {
+#if MONO
+            var res = NativeEventCalls.ResetEvent(safeWaitHandle);
+#else
             bool res = Win32Native.ResetEvent(safeWaitHandle);
+#endif
             if (!res)
+#if MONO
+                throw new IOException ();
+#else
                 __Error.WinIOError();
+#endif
             return res;
         }
         [System.Security.SecuritySafeCritical]  // auto-generated
         public bool Set()
         {
+#if MONO
+            var res = NativeEventCalls.SetEvent(safeWaitHandle);
+#else
             bool res = Win32Native.SetEvent(safeWaitHandle);
+#endif
 
             if (!res)
+#if MONO
+                throw new IOException ();
+#else
                 __Error.WinIOError();
+#endif
 
             return res;
         }
 
-#if FEATURE_MACL
+#if FEATURE_MACL || MOBILE
         [System.Security.SecuritySafeCritical]  // auto-generated
         public EventWaitHandleSecurity GetAccessControl()
         {
             return new EventWaitHandleSecurity(safeWaitHandle, AccessControlSections.Access | AccessControlSections.Owner | AccessControlSections.Group);
         }
+#endif
 
+#if FEATURE_MACL
         [System.Security.SecuritySafeCritical]  // auto-generated
         public void SetAccessControl(EventWaitHandleSecurity eventSecurity)
         {
index ae391b08948e86b49aa92aac222083d8e0214175..e97453fd717d0a302bd32563dced4cdd7ce9a7d5 100644 (file)
@@ -83,7 +83,7 @@
  * Changes which are already detected at runtime, like the addition
  * of icalls, do not require an increment.
  */
-#define MONO_CORLIB_VERSION 152
+#define MONO_CORLIB_VERSION 153
 
 typedef struct
 {
index 96cb5bd78c4f9fd85c676bb9a5f413b8a422232b..f095a5c11c92fcdb21bbd406bb60d8903cffa5d3 100644 (file)
@@ -924,8 +924,8 @@ ICALL(MUTEX_3, "ReleaseMutex_internal(intptr)", ves_icall_System_Threading_Mutex
 
 ICALL_TYPE(NATIVEC, "System.Threading.NativeEventCalls", NATIVEC_1)
 ICALL(NATIVEC_1, "CloseEvent_internal", ves_icall_System_Threading_Events_CloseEvent_internal)
-ICALL(NATIVEC_2, "CreateEvent_internal(bool,bool,string,bool&)", ves_icall_System_Threading_Events_CreateEvent_internal)
-ICALL(NATIVEC_3, "OpenEvent_internal(string,System.Security.AccessControl.EventWaitHandleRights,System.IO.MonoIOError&)", ves_icall_System_Threading_Events_OpenEvent_internal)
+ICALL(NATIVEC_2, "CreateEvent_internal(bool,bool,string,int&)", ves_icall_System_Threading_Events_CreateEvent_internal)
+ICALL(NATIVEC_3, "OpenEvent_internal(string,System.Security.AccessControl.EventWaitHandleRights,int&)", ves_icall_System_Threading_Events_OpenEvent_internal)
 ICALL(NATIVEC_4, "ResetEvent_internal",  ves_icall_System_Threading_Events_ResetEvent_internal)
 ICALL(NATIVEC_5, "SetEvent_internal",    ves_icall_System_Threading_Events_SetEvent_internal)
 
index 5b910191f6c4ff0adba5cc680d20d653d034cfb4..132dcd84e61ba9d783cd0313982b09c47a3a0337 100644 (file)
@@ -81,7 +81,7 @@ HANDLE ves_icall_System_Threading_Mutex_OpenMutex_internal (MonoString *name, gi
 HANDLE ves_icall_System_Threading_Semaphore_CreateSemaphore_internal (gint32 initialCount, gint32 maximumCount, MonoString *name, gint32 *error);
 MonoBoolean ves_icall_System_Threading_Semaphore_ReleaseSemaphore_internal (HANDLE handle, gint32 releaseCount, gint32 *prevcount);
 HANDLE ves_icall_System_Threading_Semaphore_OpenSemaphore_internal (MonoString *name, gint32 rights, gint32 *error);
-HANDLE ves_icall_System_Threading_Events_CreateEvent_internal (MonoBoolean manual, MonoBoolean initial, MonoString *name, MonoBoolean *created);
+HANDLE ves_icall_System_Threading_Events_CreateEvent_internal (MonoBoolean manual, MonoBoolean initial, MonoString *name, gint32 *error);
 gboolean ves_icall_System_Threading_Events_SetEvent_internal (HANDLE handle);
 gboolean ves_icall_System_Threading_Events_ResetEvent_internal (HANDLE handle);
 void ves_icall_System_Threading_Events_CloseEvent_internal (HANDLE handle);
index 6d7e4de2225c1dbae70376f19ef0f211b3ca89da..d9dc57ab4f65ad6c0154794572f8f28257817078 100644 (file)
@@ -1843,6 +1843,7 @@ HANDLE ves_icall_System_Threading_Semaphore_CreateSemaphore_internal (gint32 ini
        }
 
        *error = GetLastError ();
+
        return(sem);
 }                                                                   
 
@@ -1856,28 +1857,25 @@ HANDLE ves_icall_System_Threading_Semaphore_OpenSemaphore_internal (MonoString *
        HANDLE sem;
 
        sem = OpenSemaphore (rights, FALSE, mono_string_chars (name));
+
        *error = GetLastError ();
 
        return(sem);
 }
 
-HANDLE ves_icall_System_Threading_Events_CreateEvent_internal (MonoBoolean manual, MonoBoolean initial, MonoString *name, MonoBoolean *created)
+HANDLE ves_icall_System_Threading_Events_CreateEvent_internal (MonoBoolean manual, MonoBoolean initial, MonoString *name, gint32 *error)
 {
        HANDLE event;
-       
-       *created = TRUE;
 
        if (name == NULL) {
                event = CreateEvent (NULL, manual, initial, NULL);
        } else {
                event = CreateEvent (NULL, manual, initial,
                                     mono_string_chars (name));
-               
-               if (GetLastError () == ERROR_ALREADY_EXISTS) {
-                       *created = FALSE;
-               }
        }
-       
+
+       *error = GetLastError ();
+
        return(event);
 }
 
@@ -1900,13 +1898,13 @@ HANDLE ves_icall_System_Threading_Events_OpenEvent_internal (MonoString *name,
 {
        HANDLE ret;
        
-       *error = ERROR_SUCCESS;
-       
        ret = OpenEvent (rights, FALSE, mono_string_chars (name));
        if (ret == NULL) {
                *error = GetLastError ();
+       } else {
+               *error = ERROR_SUCCESS;
        }
-       
+
        return(ret);
 }