diff options
author | Jan Kotas <jkotas@microsoft.com> | 2015-08-13 19:03:13 -0700 |
---|---|---|
committer | Jan Kotas <jkotas@microsoft.com> | 2015-08-13 19:03:13 -0700 |
commit | ed73a1c96d423ff65db91758176343b8d66a137d (patch) | |
tree | 70c4129106d55a1ce5d5bf3ade1a161f0ffac9a6 | |
parent | 3275a68f04e1ccf571ba2cef2813313a1c3260f0 (diff) | |
parent | 2b42725a493e2beb11f70af8c8777891d73b4276 (diff) | |
download | coreclr-ed73a1c96d423ff65db91758176343b8d66a137d.tar.gz coreclr-ed73a1c96d423ff65db91758176343b8d66a137d.tar.bz2 coreclr-ed73a1c96d423ff65db91758176343b8d66a137d.zip |
Merge pull request #1387 from stephentoub/named_primitives
Throw PlatformNotSupported for named sync primitives on Unix
-rw-r--r-- | src/mscorlib/src/System/Threading/EventWaitHandle.cs | 26 | ||||
-rw-r--r-- | src/mscorlib/src/System/Threading/Mutex.cs | 28 | ||||
-rw-r--r-- | src/mscorlib/src/mscorlib.txt | 5 |
3 files changed, 50 insertions, 9 deletions
diff --git a/src/mscorlib/src/System/Threading/EventWaitHandle.cs b/src/mscorlib/src/System/Threading/EventWaitHandle.cs index 4a492ff8fc..5a1c14eb1e 100644 --- a/src/mscorlib/src/System/Threading/EventWaitHandle.cs +++ b/src/mscorlib/src/System/Threading/EventWaitHandle.cs @@ -48,9 +48,16 @@ namespace System.Threading [System.Security.SecurityCritical] // auto-generated_required public EventWaitHandle(bool initialState, EventResetMode mode, string name) { - if(null != name && System.IO.Path.MAX_PATH < name.Length) + if (name != null) { - throw new ArgumentException(Environment.GetResourceString("Argument_WaitHandleNameTooLong",name)); +#if PLATFORM_UNIX + throw new PlatformNotSupportedException(Environment.GetResourceString("PlatformNotSupported_NamedSynchronizationPrimitives")); +#else + if (System.IO.Path.MAX_PATH < name.Length) + { + throw new ArgumentException(Environment.GetResourceString("Argument_WaitHandleNameTooLong", name)); + } +#endif } Contract.EndContractBlock(); @@ -90,9 +97,16 @@ namespace System.Threading [System.Security.SecurityCritical] // auto-generated_required public unsafe EventWaitHandle(bool initialState, EventResetMode mode, string name, out bool createdNew, EventWaitHandleSecurity eventSecurity) { - if(null != name && System.IO.Path.MAX_PATH < name.Length) + if (name != null) { - throw new ArgumentException(Environment.GetResourceString("Argument_WaitHandleNameTooLong",name)); +#if PLATFORM_UNIX + throw new PlatformNotSupportedException(Environment.GetResourceString("PlatformNotSupported_NamedSynchronizationPrimitives")); +#else + if (System.IO.Path.MAX_PATH < name.Length) + { + throw new ArgumentException(Environment.GetResourceString("Argument_WaitHandleNameTooLong", name)); + } +#endif } Contract.EndContractBlock(); Win32Native.SECURITY_ATTRIBUTES secAttrs = null; @@ -196,6 +210,9 @@ namespace System.Threading [System.Security.SecurityCritical] // auto-generated_required private static OpenExistingResult OpenExistingWorker(string name, EventWaitHandleRights rights, out EventWaitHandle result) { +#if PLATFORM_UNIX + throw new PlatformNotSupportedException(Environment.GetResourceString("PlatformNotSupported_NamedSynchronizationPrimitives")); +#else if (name == null) { throw new ArgumentNullException("name", Environment.GetResourceString("ArgumentNull_WithParamName")); @@ -236,6 +253,7 @@ namespace System.Threading } result = new EventWaitHandle(myHandle); return OpenExistingResult.Success; +#endif } [System.Security.SecuritySafeCritical] // auto-generated public bool Reset() diff --git a/src/mscorlib/src/System/Threading/Mutex.cs b/src/mscorlib/src/System/Threading/Mutex.cs index 2621480c2c..35c68cda6c 100644 --- a/src/mscorlib/src/System/Threading/Mutex.cs +++ b/src/mscorlib/src/System/Threading/Mutex.cs @@ -52,10 +52,17 @@ namespace System.Threading [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] public unsafe Mutex(bool initiallyOwned, String name, out bool createdNew, MutexSecurity mutexSecurity) { - if(null != name && System.IO.Path.MAX_PATH < name.Length) + if (name != null) { - throw new ArgumentException(Environment.GetResourceString("Argument_WaitHandleNameTooLong",name)); - } +#if PLATFORM_UNIX + throw new PlatformNotSupportedException(Environment.GetResourceString("PlatformNotSupported_NamedSynchronizationPrimitives")); +#else + if (System.IO.Path.MAX_PATH < name.Length) + { + throw new ArgumentException(Environment.GetResourceString("Argument_WaitHandleNameTooLong", name)); + } +#endif + } Contract.EndContractBlock(); Win32Native.SECURITY_ATTRIBUTES secAttrs = null; #if FEATURE_MACL @@ -79,9 +86,16 @@ namespace System.Threading [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] internal Mutex(bool initiallyOwned, String name, out bool createdNew, Win32Native.SECURITY_ATTRIBUTES secAttrs) { - if (null != name && Path.MAX_PATH < name.Length) + if (name != null) { - throw new ArgumentException(Environment.GetResourceString("Argument_WaitHandleNameTooLong", name)); +#if PLATFORM_UNIX + throw new PlatformNotSupportedException(Environment.GetResourceString("PlatformNotSupported_NamedSynchronizationPrimitives")); +#else + if (System.IO.Path.MAX_PATH < name.Length) + { + throw new ArgumentException(Environment.GetResourceString("Argument_WaitHandleNameTooLong", name)); + } +#endif } Contract.EndContractBlock(); @@ -321,6 +335,9 @@ namespace System.Threading [System.Security.SecurityCritical] private static OpenExistingResult OpenExistingWorker(string name, MutexRights rights, out Mutex result) { +#if PLATFORM_UNIX + throw new PlatformNotSupportedException(Environment.GetResourceString("PlatformNotSupported_NamedSynchronizationPrimitives")); +#else if (name == null) { throw new ArgumentNullException("name", Environment.GetResourceString("ArgumentNull_WithParamName")); @@ -371,6 +388,7 @@ namespace System.Threading result = new Mutex(myHandle); return OpenExistingResult.Success; +#endif } // Note: To call ReleaseMutex, you must have an ACL granting you diff --git a/src/mscorlib/src/mscorlib.txt b/src/mscorlib/src/mscorlib.txt index 39a40d2b0f..d3e4cea674 100644 --- a/src/mscorlib/src/mscorlib.txt +++ b/src/mscorlib/src/mscorlib.txt @@ -2130,6 +2130,11 @@ event_SpinLock_FastPathFailed=SpinLock beginning to spin. event_SpinWait_NextSpinWillYield=Next spin will yield. event_Barrier_PhaseFinished=Barrier finishing phase {1}. +#if PLATFORM_UNIX +; Unix threading +PlatformNotSupported_NamedSynchronizationPrimitives=Named synchronization primitives are not supported on this platform. +#endif + ; ; System.Threading.Tasks ; |