protected virtual void Dispose(bool disposing)
{
- if (!disposing)
- {
- return;
- }
-
if (NetEventSource.IsEnabled)
{
try
{
- NetEventSource.Info(this, $"disposing:true CleanedUp:{CleanedUp}");
+ NetEventSource.Info(this, $"disposing:{disposing} CleanedUp:{CleanedUp}");
NetEventSource.Enter(this);
}
catch (Exception exception) when (!ExceptionCheck.IsFatal(exception)) { }
try
{
int timeout = _closeTimeout;
- if (timeout == 0)
+ if (timeout == 0 || !disposing)
{
// Abortive.
if (NetEventSource.IsEnabled) NetEventSource.Info(this, "Calling _handle.Dispose()");
- _handle.Dispose();
+ _handle?.Dispose();
}
else
{
{
public partial class DisposedSocket
{
- [ActiveIssue(37044, TestPlatforms.AnyUnix)]
[Theory]
[InlineData(false)]
[InlineData(true)]
RetryHelper.Execute(() =>
{
GC.Collect();
+ GC.WaitForPendingFinalizers();
Assert.Equal(0, handles.Count(h => h.IsAlive));
});
}