Imported Upstream version 4.3.2.467

Former-commit-id: 9c2cb47f45fa221e661ab616387c9cda183f283d
This commit is contained in:
Xamarin Public Jenkins
2016-02-22 11:00:01 -05:00
parent f302175246
commit f3e3aab35a
4097 changed files with 122406 additions and 82300 deletions

View File

@@ -31,6 +31,11 @@ namespace Microsoft.Win32.SafeHandles {
SetHandle(preexistingHandle);
}
#if MOBILE
override protected bool ReleaseHandle() {
return true;
}
#else
[System.Security.SecurityCritical]
override protected bool ReleaseHandle() {
return (RegCloseKey(handle) == Win32Native.ERROR_SUCCESS);
@@ -41,6 +46,7 @@ namespace Microsoft.Win32.SafeHandles {
ResourceExposure(ResourceScope.None),
ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal static extern int RegCloseKey(IntPtr hKey);
#endif
}
}
#endif // !FEATURE_PAL

View File

@@ -29,21 +29,6 @@ namespace Microsoft.Win32.SafeHandles {
[System.Security.SecurityCritical] // auto-generated_required
public sealed class SafeWaitHandle : SafeHandleZeroOrMinusOneIsInvalid
{
// Special case flags for Mutexes enables workaround for known OS bug at
// http://support.microsoft.com/default.aspx?scid=kb;en-us;889318
// One machine-wide mutex serializes all OpenMutex and CloseHandle operations.
// bIsMutex: if true, we need to grab machine-wide mutex before doing any Close ops.
// Initialized to false by the runtime.
private bool bIsMutex;
// bIsMutex: if true, we need to avoid grabbing the machine-wide mutex before Close ops,
// since that mutex is, of course, this very handle.
// Initialized to false by the runtime.
private bool bIsReservedMutex;
// Called by P/Invoke marshaler
private SafeWaitHandle() : base(true)
{
@@ -63,42 +48,9 @@ namespace Microsoft.Win32.SafeHandles {
#if MONO
NativeEventCalls.CloseEvent_internal (handle);
return true;
#else
#if !FEATURE_CORECLR
if (!bIsMutex || Environment.HasShutdownStarted)
return Win32Native.CloseHandle(handle);
bool bReturn = false;
bool bMutexObtained = false;
try
{
if (!bIsReservedMutex)
{
Mutex.AcquireReservedMutex(ref bMutexObtained);
}
bReturn = Win32Native.CloseHandle(handle);
}
finally
{
if (bMutexObtained)
Mutex.ReleaseReservedMutex();
}
return bReturn;
#else
return Win32Native.CloseHandle(handle);
#endif
#endif
}
internal void SetAsMutex()
{
bIsMutex = true;
}
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal void SetAsReservedMutex()
{
bIsReservedMutex = true;
}
}
}