Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/mcs
diff options
context:
space:
mode:
authorDick Porter <dick@acm.org>2005-12-23 23:29:06 +0300
committerDick Porter <dick@acm.org>2005-12-23 23:29:06 +0300
commit8265935e1be8e419424e27753aa822a3062c8127 (patch)
tree386699a4e1f06e6b9e8eea0751e10e792f3f7b36 /mcs
parentceb3a50eb605a62156f6a0e8d82e5ff1e9d2d51f (diff)
2005-12-23 Dick Porter <dick@ximian.com>
* EventWaitHandle.cs: * Mutex.cs: Implement OpenExisting * NativeEventCalls.cs: Add OpenEvent icall for OpenExisting in 2.0. Add a "created" boolean out parameter to CreateEvent icall. * ManualResetEvent.cs: * AutoResetEvent.cs: Update CreateEvent icall signature (now has "created" boolean out parameter.) 2005-12-23 Dick Porter <dick@ximian.com> * Semaphore.cs: Implement OpenExisting 2005-12-23 Dick Porter <dick@ximian.com> * MutexRights.cs: New for 2.0 profile 2005-12-23 Dick Porter <dick@ximian.com> * SemaphoreRights.cs: Make the [Flags] enum more obvious 2005-12-23 Dick Porter <dick@ximian.com> * SemaphoreTest.cs: Enable another test 2005-12-23 Dick Porter <dick@ximian.com> * corlib.dll.sources: Added System.Security.AccessControl.MutexRights svn path=/trunk/mcs/; revision=54801
Diffstat (limited to 'mcs')
-rw-r--r--mcs/class/System/System.Security.AccessControl/ChangeLog4
-rw-r--r--mcs/class/System/System.Security.AccessControl/SemaphoreRights.cs14
-rw-r--r--mcs/class/System/System.Threading/ChangeLog4
-rw-r--r--mcs/class/System/System.Threading/Semaphore.cs25
-rw-r--r--mcs/class/System/Test/System.Threading/ChangeLog4
-rw-r--r--mcs/class/System/Test/System.Threading/SemaphoreTest.cs1
-rw-r--r--mcs/class/corlib/ChangeLog4
-rw-r--r--mcs/class/corlib/System.Security.AccessControl/ChangeLog4
-rw-r--r--mcs/class/corlib/System.Security.AccessControl/MutexRights.cs45
-rw-r--r--mcs/class/corlib/System.Threading/AutoResetEvent.cs4
-rw-r--r--mcs/class/corlib/System.Threading/ChangeLog12
-rw-r--r--mcs/class/corlib/System.Threading/EventWaitHandle.cs46
-rw-r--r--mcs/class/corlib/System.Threading/ManualResetEvent.cs4
-rw-r--r--mcs/class/corlib/System.Threading/Mutex.cs48
-rw-r--r--mcs/class/corlib/System.Threading/NativeEventCalls.cs12
-rw-r--r--mcs/class/corlib/corlib.dll.sources3
16 files changed, 208 insertions, 26 deletions
diff --git a/mcs/class/System/System.Security.AccessControl/ChangeLog b/mcs/class/System/System.Security.AccessControl/ChangeLog
index a6210881364..d17e2d555c2 100644
--- a/mcs/class/System/System.Security.AccessControl/ChangeLog
+++ b/mcs/class/System/System.Security.AccessControl/ChangeLog
@@ -1,3 +1,7 @@
+2005-12-23 Dick Porter <dick@ximian.com>
+
+ * SemaphoreRights.cs: Make the [Flags] enum more obvious
+
2005-11-17 Sebastien Pouliot <sebastien@ximian.com>
* SemaphoreRights.cs: New (2.0). Enum of all the rights applicable to
diff --git a/mcs/class/System/System.Security.AccessControl/SemaphoreRights.cs b/mcs/class/System/System.Security.AccessControl/SemaphoreRights.cs
index 79d77763859..f3163c99581 100644
--- a/mcs/class/System/System.Security.AccessControl/SemaphoreRights.cs
+++ b/mcs/class/System/System.Security.AccessControl/SemaphoreRights.cs
@@ -35,13 +35,13 @@ namespace System.Security.AccessControl {
[ComVisible (false)]
[Flags]
public enum SemaphoreRights {
- Modify = 2,
- Delete = 65536,
- ReadPermissions = 131072,
- ChangePermissions = 262144,
- TakeOwnership = 524288,
- Synchronize = 1048576,
- FullControl = 2031619
+ Modify = 0x000002,
+ Delete = 0x010000,
+ ReadPermissions = 0x020000,
+ ChangePermissions = 0x040000,
+ TakeOwnership = 0x080000,
+ Synchronize = 0x100000,
+ FullControl = 0x1F0003 /* not 0x1F0002 according to corcompare */
}
}
diff --git a/mcs/class/System/System.Threading/ChangeLog b/mcs/class/System/System.Threading/ChangeLog
index 3b6cad51cb9..a7485029884 100644
--- a/mcs/class/System/System.Threading/ChangeLog
+++ b/mcs/class/System/System.Threading/ChangeLog
@@ -1,3 +1,7 @@
+2005-12-23 Dick Porter <dick@ximian.com>
+
+ * Semaphore.cs: Implement OpenExisting
+
2005-11-26 Dick Porter <dick@ximian.com>
* Semaphore.cs: Implemented with icalls
diff --git a/mcs/class/System/System.Threading/Semaphore.cs b/mcs/class/System/System.Threading/Semaphore.cs
index 02f84417748..c192d368275 100644
--- a/mcs/class/System/System.Threading/Semaphore.cs
+++ b/mcs/class/System/System.Threading/Semaphore.cs
@@ -32,6 +32,7 @@ using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
using System.Security.AccessControl;
using System.Runtime.CompilerServices;
+using System.IO;
namespace System.Threading {
@@ -47,6 +48,14 @@ namespace System.Threading {
private static extern int ReleaseSemaphore_internal (
IntPtr handle, int releaseCount, out bool fail);
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ private static extern IntPtr OpenSemaphore_internal (string name, SemaphoreRights rights, out MonoIOError error);
+
+ private Semaphore (IntPtr handle)
+ {
+ Handle = handle;
+ }
+
public Semaphore (int initialCount, int maximumCount)
: this (initialCount, maximumCount, null)
{
@@ -137,7 +146,6 @@ namespace System.Threading {
return OpenExisting (name, SemaphoreRights.Synchronize | SemaphoreRights.Modify);
}
- [MonoTODO]
public static Semaphore OpenExisting (string name, SemaphoreRights rights)
{
if (name == null)
@@ -145,7 +153,20 @@ namespace System.Threading {
if ((name.Length ==0) || (name.Length > 260))
throw new ArgumentException ("name", Locale.GetText ("Invalid length [1-260]."));
- throw new NotImplementedException ();
+ MonoIOError error;
+ IntPtr handle = OpenSemaphore_internal (name, rights,
+ out error);
+ if (handle == (IntPtr)null) {
+ if (error == MonoIOError.ERROR_FILE_NOT_FOUND) {
+ throw new WaitHandleCannotBeOpenedException (Locale.GetText ("Named Semaphore 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 Semaphore (handle));
}
}
}
diff --git a/mcs/class/System/Test/System.Threading/ChangeLog b/mcs/class/System/Test/System.Threading/ChangeLog
index bc781acc19d..2b0cab895bd 100644
--- a/mcs/class/System/Test/System.Threading/ChangeLog
+++ b/mcs/class/System/Test/System.Threading/ChangeLog
@@ -1,3 +1,7 @@
+2005-12-23 Dick Porter <dick@ximian.com>
+
+ * SemaphoreTest.cs: Enable another test
+
2005-12-06 Dick Porter <dick@ximian.com>
* SemaphoreTest.cs: Enable the tests
diff --git a/mcs/class/System/Test/System.Threading/SemaphoreTest.cs b/mcs/class/System/Test/System.Threading/SemaphoreTest.cs
index e21823f80c6..9e5db531fd0 100644
--- a/mcs/class/System/Test/System.Threading/SemaphoreTest.cs
+++ b/mcs/class/System/Test/System.Threading/SemaphoreTest.cs
@@ -212,7 +212,6 @@ namespace MonoTests.System.Threading {
}
[Test]
- [Category ("NotWorking")] // not implemented in Mono
[ExpectedException (typeof (WaitHandleCannotBeOpenedException))]
public void OpenExisting_Unexisting ()
{
diff --git a/mcs/class/corlib/ChangeLog b/mcs/class/corlib/ChangeLog
index 5105b6130b3..5ad674f442e 100644
--- a/mcs/class/corlib/ChangeLog
+++ b/mcs/class/corlib/ChangeLog
@@ -1,3 +1,7 @@
+2005-12-23 Dick Porter <dick@ximian.com>
+
+ * corlib.dll.sources: Added System.Security.AccessControl.MutexRights
+
2005-12-17 Dick Porter <dick@ximian.com>
* corlib.dll.sources: Added in System.Security.AccessControl:
diff --git a/mcs/class/corlib/System.Security.AccessControl/ChangeLog b/mcs/class/corlib/System.Security.AccessControl/ChangeLog
index 6296d45d8ae..c3040a1c30f 100644
--- a/mcs/class/corlib/System.Security.AccessControl/ChangeLog
+++ b/mcs/class/corlib/System.Security.AccessControl/ChangeLog
@@ -1,3 +1,7 @@
+2005-12-23 Dick Porter <dick@ximian.com>
+
+ * MutexRights.cs: New for 2.0 profile
+
2005-12-17 Dick Porter <dick@ximian.com>
* EventWaitHandleRights.cs: New for 2.0 profile
diff --git a/mcs/class/corlib/System.Security.AccessControl/MutexRights.cs b/mcs/class/corlib/System.Security.AccessControl/MutexRights.cs
new file mode 100644
index 00000000000..120d3710818
--- /dev/null
+++ b/mcs/class/corlib/System.Security.AccessControl/MutexRights.cs
@@ -0,0 +1,45 @@
+//
+// System.Security.AccessControl.MutexRights enum
+//
+// Author:
+// Dick Porter <dick@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.
+//
+
+#if NET_2_0
+
+namespace System.Security.AccessControl {
+
+ [Flags]
+ public enum MutexRights {
+ Modify = 0x000001,
+ Delete = 0x010000,
+ ReadPermissions = 0x020000,
+ ChangePermissions = 0x040000,
+ TakeOwnership = 0x080000,
+ Synchronize = 0x100000,
+ FullControl = 0x1F0001
+ }
+}
+
+#endif
diff --git a/mcs/class/corlib/System.Threading/AutoResetEvent.cs b/mcs/class/corlib/System.Threading/AutoResetEvent.cs
index 5306ba4e81a..414ec6e4907 100644
--- a/mcs/class/corlib/System.Threading/AutoResetEvent.cs
+++ b/mcs/class/corlib/System.Threading/AutoResetEvent.cs
@@ -52,7 +52,9 @@ namespace System.Threading
}
#else
public AutoResetEvent(bool initialState) {
- Handle = NativeEventCalls.CreateEvent_internal(false,initialState,null);
+ bool created;
+
+ Handle = NativeEventCalls.CreateEvent_internal(false,initialState,null, out created);
}
#endif
diff --git a/mcs/class/corlib/System.Threading/ChangeLog b/mcs/class/corlib/System.Threading/ChangeLog
index 19cde7d246d..4f0ffb33a44 100644
--- a/mcs/class/corlib/System.Threading/ChangeLog
+++ b/mcs/class/corlib/System.Threading/ChangeLog
@@ -1,3 +1,15 @@
+2005-12-23 Dick Porter <dick@ximian.com>
+
+ * EventWaitHandle.cs:
+ * Mutex.cs: Implement OpenExisting
+
+ * NativeEventCalls.cs: Add OpenEvent icall for OpenExisting in
+ 2.0. Add a "created" boolean out parameter to CreateEvent icall.
+
+ * ManualResetEvent.cs:
+ * AutoResetEvent.cs: Update CreateEvent icall signature (now has
+ "created" boolean out parameter.)
+
2005-12-17 Dick Porter <dick@ximian.com>
* ThreadStartException.cs:
diff --git a/mcs/class/corlib/System.Threading/EventWaitHandle.cs b/mcs/class/corlib/System.Threading/EventWaitHandle.cs
index 3cb56ae2435..e1ac46fc160 100644
--- a/mcs/class/corlib/System.Threading/EventWaitHandle.cs
+++ b/mcs/class/corlib/System.Threading/EventWaitHandle.cs
@@ -30,37 +30,44 @@
#if NET_2_0
using System.Security.AccessControl;
+using System.IO;
namespace System.Threading
{
public class EventWaitHandle : WaitHandle
{
+ private EventWaitHandle (IntPtr handle)
+ {
+ Handle = handle;
+ }
+
public EventWaitHandle (bool initialState, EventResetMode mode)
{
- Handle = NativeEventCalls.CreateEvent_internal ((mode == EventResetMode.ManualReset), initialState, null);
+ bool created;
+
+ Handle = NativeEventCalls.CreateEvent_internal ((mode == EventResetMode.ManualReset), initialState, null, out created);
}
public EventWaitHandle (bool initialState, EventResetMode mode,
string name)
{
- Handle = NativeEventCalls.CreateEvent_internal ((mode == EventResetMode.ManualReset), initialState, name);
+ bool created;
+
+ Handle = NativeEventCalls.CreateEvent_internal ((mode == EventResetMode.ManualReset), initialState, name, out created);
}
- [MonoTODO ("Implement createdNew")]
public EventWaitHandle (bool initialState, EventResetMode mode,
string name, out bool createdNew)
{
- Handle = NativeEventCalls.CreateEvent_internal ((mode == EventResetMode.ManualReset), initialState, name);
- createdNew = false;
+ Handle = NativeEventCalls.CreateEvent_internal ((mode == EventResetMode.ManualReset), initialState, name, out createdNew);
}
- [MonoTODO ("Implement createdNew and access control")]
+ [MonoTODO ("Implement access control")]
public EventWaitHandle (bool initialState, EventResetMode mode,
string name, out bool createdNew,
EventWaitHandleSecurity eventSecurity)
{
- Handle = NativeEventCalls.CreateEvent_internal ((mode == EventResetMode.ManualReset), initialState, name);
- createdNew = false;
+ Handle = NativeEventCalls.CreateEvent_internal ((mode == EventResetMode.ManualReset), initialState, name, out createdNew);
}
[MonoTODO]
@@ -74,10 +81,29 @@ namespace System.Threading
return(OpenExisting (name, EventWaitHandleRights.Synchronize | EventWaitHandleRights.Modify));
}
- [MonoTODO]
public static EventWaitHandle OpenExisting (string name, EventWaitHandleRights rights)
{
- throw new NotImplementedException ();
+ 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 bool Reset ()
diff --git a/mcs/class/corlib/System.Threading/ManualResetEvent.cs b/mcs/class/corlib/System.Threading/ManualResetEvent.cs
index 31eaacf9904..ba7c6968f68 100644
--- a/mcs/class/corlib/System.Threading/ManualResetEvent.cs
+++ b/mcs/class/corlib/System.Threading/ManualResetEvent.cs
@@ -53,7 +53,9 @@ namespace System.Threading
#else
public ManualResetEvent (bool initialState)
{
- Handle = NativeEventCalls.CreateEvent_internal (true, initialState, null);
+ bool created;
+
+ Handle = NativeEventCalls.CreateEvent_internal (true, initialState, null, out created);
}
#endif
diff --git a/mcs/class/corlib/System.Threading/Mutex.cs b/mcs/class/corlib/System.Threading/Mutex.cs
index 9a6de58e136..423b59d926a 100644
--- a/mcs/class/corlib/System.Threading/Mutex.cs
+++ b/mcs/class/corlib/System.Threading/Mutex.cs
@@ -34,6 +34,7 @@ using System.Security.Permissions;
#if NET_2_0
using System.Runtime.ConstrainedExecution;
using System.Security.AccessControl;
+using System.IO;
#endif
namespace System.Threading
@@ -50,6 +51,16 @@ namespace System.Threading
private static extern void ReleaseMutex_internal(IntPtr handle);
#if NET_2_0
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ private static extern IntPtr OpenMutex_internal (string name, MutexRights rights, out MonoIOError error);
+
+ private Mutex (IntPtr handle)
+ {
+ Handle = handle;
+ }
+#endif
+
+#if NET_2_0
[ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.MayFail)]
#endif
public Mutex() {
@@ -88,11 +99,44 @@ namespace System.Threading
}
#if NET_2_0
- [MonoTODO]
+ [MonoTODO ("Implement MutexSecurity")]
[ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.MayFail)]
public Mutex (bool initiallyOwned, string name, out bool createdNew, MutexSecurity mutexSecurity)
{
- throw new NotImplementedException ();
+ Handle = CreateMutex_internal (initiallyOwned, name, out createdNew);
+ }
+
+ public static Mutex OpenExisting (string name)
+ {
+ return(OpenExisting (name, MutexRights.Synchronize |
+ MutexRights.Modify));
+ }
+
+ public static Mutex OpenExisting (string name,
+ MutexRights 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 = OpenMutex_internal (name, rights,
+ out error);
+ if (handle == (IntPtr)null) {
+ if (error == MonoIOError.ERROR_FILE_NOT_FOUND) {
+ throw new WaitHandleCannotBeOpenedException (Locale.GetText ("Named Mutex 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 Mutex (handle));
}
#endif
diff --git a/mcs/class/corlib/System.Threading/NativeEventCalls.cs b/mcs/class/corlib/System.Threading/NativeEventCalls.cs
index 6f4c1b546c4..c73cf248c06 100644
--- a/mcs/class/corlib/System.Threading/NativeEventCalls.cs
+++ b/mcs/class/corlib/System.Threading/NativeEventCalls.cs
@@ -34,12 +34,17 @@
using System;
using System.Runtime.CompilerServices;
+#if NET_2_0
+using System.Security.AccessControl;
+using System.IO;
+#endif
+
namespace System.Threading
{
internal sealed class NativeEventCalls
{
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern IntPtr CreateEvent_internal(bool manual,bool initial,string name);
+ public static extern IntPtr CreateEvent_internal(bool manual,bool initial,string name, out bool created);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public static extern bool SetEvent_internal(IntPtr handle);
@@ -49,5 +54,10 @@ namespace System.Threading
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public static extern void CloseEvent_internal (IntPtr handle);
+
+#if NET_2_0
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ public static extern IntPtr OpenEvent_internal (string name, EventWaitHandleRights rights, out MonoIOError error);
+#endif
}
}
diff --git a/mcs/class/corlib/corlib.dll.sources b/mcs/class/corlib/corlib.dll.sources
index 6b579a69209..d9af9e1a86f 100644
--- a/mcs/class/corlib/corlib.dll.sources
+++ b/mcs/class/corlib/corlib.dll.sources
@@ -1041,9 +1041,10 @@ System.Security.AccessControl/CryptoKeySecurity.cs
System.Security.AccessControl/DirectorySecurity.cs
System.Security.AccessControl/EventWaitHandleRights.cs
System.Security.AccessControl/EventWaitHandleSecurity.cs
-System.Security.AccessControl/ObjectSecurity.cs
+System.Security.AccessControl/MutexRights.cs
System.Security.AccessControl/MutexSecurity.cs
System.Security.AccessControl/NativeObjectSecurity.cs
+System.Security.AccessControl/ObjectSecurity.cs
System.Security.Cryptography/AsymmetricAlgorithm.cs
System.Security.Cryptography/AsymmetricKeyExchangeDeformatter.cs
System.Security.Cryptography/AsymmetricKeyExchangeFormatter.cs