summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Kotas <jkotas@microsoft.com>2018-12-30 23:18:23 -0800
committerJan Kotas <jkotas@microsoft.com>2018-12-30 22:55:37 -1000
commit18d3d48f1148ff1e4742518916226767e6520cf1 (patch)
tree147c8998cfb30aef90a1238ba70efd50a2b18902
parente4959bbc9127d4635a7f38e9aa9dd4a74d0e2703 (diff)
downloadcoreclr-18d3d48f1148ff1e4742518916226767e6520cf1.tar.gz
coreclr-18d3d48f1148ff1e4742518916226767e6520cf1.tar.bz2
coreclr-18d3d48f1148ff1e4742518916226767e6520cf1.zip
Add license, keep more of the CriticalHandle logic in the shared file
-rw-r--r--src/System.Private.CoreLib/shared/System/Runtime/InteropServices/CriticalHandle.cs18
-rw-r--r--src/System.Private.CoreLib/src/System/Runtime/InteropServices/CriticalHandle.CoreCLR.cs21
-rw-r--r--src/vm/ecalllist.h2
3 files changed, 17 insertions, 24 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/CriticalHandle.cs b/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/CriticalHandle.cs
index acb94c4b0e..7b8c4625e3 100644
--- a/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/CriticalHandle.cs
+++ b/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/CriticalHandle.cs
@@ -45,13 +45,7 @@
**
===========================================================*/
-using System;
-using System.Reflection;
-using System.Threading;
-using System.Runtime.CompilerServices;
-using System.Runtime.Versioning;
using System.Runtime.ConstrainedExecution;
-using System.IO;
/*
Problems addressed by the CriticalHandle class:
@@ -154,7 +148,15 @@ namespace System.Runtime.InteropServices
if (IsInvalid)
return;
- ReleaseHandleCore();
+ // Save last error from P/Invoke in case the implementation of
+ // ReleaseHandle trashes it (important because this ReleaseHandle could
+ // occur implicitly as part of unmarshaling another P/Invoke).
+ int lastError = Marshal.GetLastWin32Error();
+
+ if (!ReleaseHandle())
+ ReleaseHandleFailed();
+
+ Marshal.SetLastWin32Error(lastError);
GC.SuppressFinalize(this);
}
@@ -211,7 +213,7 @@ namespace System.Runtime.InteropServices
// you can deal with the failure and still free the handle).
// The boolean returned should be true for success and false if a
// catastrophic error occurred and you wish to trigger a diagnostic for
- // debugging purposes (the SafeHandleCriticalFailure MDA).
+ // debugging purposes.
protected abstract bool ReleaseHandle();
}
}
diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/CriticalHandle.CoreCLR.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/CriticalHandle.CoreCLR.cs
index 8c4dfee270..803504a057 100644
--- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/CriticalHandle.CoreCLR.cs
+++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/CriticalHandle.CoreCLR.cs
@@ -1,3 +1,7 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
using System.Runtime.CompilerServices;
using System.Runtime.ConstrainedExecution;
@@ -5,20 +9,7 @@ namespace System.Runtime.InteropServices
{
public abstract partial class CriticalHandle : CriticalFinalizerObject, IDisposable
{
- void ReleaseHandleCore()
- {
- // Save last error from P/Invoke in case the implementation of
- // ReleaseHandle trashes it (important because this ReleaseHandle could
- // occur implicitly as part of unmarshaling another P/Invoke).
- int lastError = Marshal.GetLastWin32Error();
-
- if (!ReleaseHandle())
- FireCustomerDebugProbe();
-
- Marshal.SetLastWin32Error(lastError);
- }
-
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- private extern void FireCustomerDebugProbe();
+ private extern void ReleaseHandleFailed();
}
-} \ No newline at end of file
+}
diff --git a/src/vm/ecalllist.h b/src/vm/ecalllist.h
index c8244a69e8..2d07ac39aa 100644
--- a/src/vm/ecalllist.h
+++ b/src/vm/ecalllist.h
@@ -188,7 +188,7 @@ FCFuncStart(gSafeHandleFuncs)
FCFuncEnd()
FCFuncStart(gCriticalHandleFuncs)
- FCFuncElement("FireCustomerDebugProbe", CriticalHandle::FireCustomerDebugProbe)
+ FCFuncElement("ReleaseHandleFailed", CriticalHandle::FireCustomerDebugProbe)
FCFuncEnd()
FCFuncStart(gTypedReferenceFuncs)