On Thu, 2011-01-20 at 16:15 +0000, Dick Porter wrote:
> On 17 Jan 2011, at 6:00PM, Rodrigo Kumpera wrote:
> > I'm not sure what the defined behavior is on this case, MSDN is not  
> > always accurate and we
> > need to be as compatible with MS as possible.
> >
> > Could you please write a test case, and if the behavior you suggest  
> > is correct, send a patch
> > which includes both the fix and the test case so we can move forward?
> 
> Please see attached test case and diff.

I think a more correct patch would be the one attached. Avoids having
'if (Invalid) return;' followed by 'if (!Invalid)...'.

-Gonzalo

diff --git a/mcs/class/corlib/System.Runtime.InteropServices/CriticalHandle.cs b/mcs/class/corlib/System.Runtime.InteropServices/CriticalHandle.cs
index 479dc44..ce50aff 100644
--- a/mcs/class/corlib/System.Runtime.InteropServices/CriticalHandle.cs
+++ b/mcs/class/corlib/System.Runtime.InteropServices/CriticalHandle.cs
@@ -47,17 +47,14 @@ namespace System.Runtime.InteropServices
 			if (_disposed)
 				return;
 
-			_disposed = true;
-			if (IsInvalid)
-				return;
-
-			if (disposing == true && !IsInvalid){
-				if (!ReleaseHandle ()) {
+			if (!IsInvalid){
+				if (!_disposed && !ReleaseHandle ()) {
 					GC.SuppressFinalize (this);
 				} else {
 					// Failed in release...
 				}
 			}
+			_disposed = true;
 		}
 
 		[ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
_______________________________________________
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list

Reply via email to