@@ -688,35 +688,6 @@ public unsafe void Ctor_SafeHandle_SocketPair_Success()
688688 close ( ptr [ 1 ] ) ;
689689 }
690690
691- // On some Unix machines the second (manual) handle close succeeds despite Socket's/SafeSocketHandle's Dispose
692- // completing a succesful close of the same handle value previously.
693- // We may investigate this, but it doesn't indicate incorrect behavior in Socket code,
694- // so making the test PlatformSpecific seems to be good enough. The SafeSocketHandle lifecycle logic is platform cross-platform.
695- [ PlatformSpecific ( TestPlatforms . Windows ) ]
696- [ Theory ]
697- [ InlineData ( false ) ]
698- [ InlineData ( true ) ]
699- public void Ctor_Dispose_HandleClosedIfOwnsHandle ( bool ownsHandle )
700- {
701- Socket original = new Socket ( AddressFamily . InterNetwork , SocketType . Dgram , ProtocolType . Udp ) ;
702- IntPtr handleValue = original . Handle ;
703-
704- SafeSocketHandle handleClone = new SafeSocketHandle ( handleValue , ownsHandle : ownsHandle ) ;
705- Socket socketClone = new Socket ( handleClone ) ;
706- socketClone . Dispose ( ) ;
707-
708- bool manualCloseSucceeded = closesocket ( handleValue ) == 0 ;
709- Assert . Equal ( ! ownsHandle , manualCloseSucceeded ) ;
710-
711- #if DEBUG // The finalizer will fail to close the handle which leads to an assertion failure in Debug builds.
712- GC . SuppressFinalize ( original ) ;
713- GC . SuppressFinalize ( original . SafeHandle ) ;
714- #endif
715-
716- [ DllImport ( "ws2_32.dll" , SetLastError = true ) ]
717- static extern int closesocket ( IntPtr socketHandle ) ;
718- }
719-
720691 private static void AssertEqualOrSameException < T > ( Func < T > expected , Func < T > actual )
721692 {
722693 T r1 = default , r2 = default ;
0 commit comments