internal void CloseAsIs()
{
if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"_innerSocket={_innerSocket}");
#if DEBUG
// If this throws it could be very bad.
try
{
#endif
InnerSafeCloseSocket innerSocket = _innerSocket == null ? null : Interlocked.Exchange<InnerSafeCloseSocket>(ref _innerSocket, null);
Dispose();
if (innerSocket != null)
{
// Wait until it's safe.
SpinWait sw = new SpinWait();
while (!_released)
{
sw.SpinOnce();
}
// Now free it with blocking.
innerSocket.BlockingRelease();
}
InnerReleaseHandle();
#if DEBUG
}
catch (Exception exception) when (!ExceptionCheck.IsFatal(exception))
{
NetEventSource.Fail(this, $"handle:{handle}, error:{exception}");
throw;
}
#endif
}