Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

make sure we close OS handle if socket is finalized without disposing #38499

Merged
merged 2 commits into from
Jun 16, 2019

Conversation

wfurt
Copy link
Member

@wfurt wfurt commented Jun 13, 2019

If socket is finalized without disposing we currently leak OS socket as Dispose(false) does nothing.

With this change, socket finalizer should nuke OS fd.
I originally forked CloseAsIs() but it seems like disposing _handle is sufficient.

The test @stephentoub wrote give me some grief.
It seems like EventLoop() can hold reference to SocketAsyncContext until new event kicks in.
I decided to explicitly drop that so we are more likely to release handle if finalize socket but there is no other activity for a while.

fixes dotnet/runtime#29327

@wfurt wfurt requested review from tmds and stephentoub June 13, 2019 09:23
@wfurt wfurt self-assigned this Jun 13, 2019
@wfurt
Copy link
Member Author

wfurt commented Jun 13, 2019

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 4 pipeline(s).

Copy link
Member

@tmds tmds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@davidsh davidsh added this to the 3.0 milestone Jun 13, 2019
@wfurt
Copy link
Member Author

wfurt commented Jun 14, 2019

I want back and it behaves as you described @stephentoub. I guess I got confused somewhere early and I modified test and never got back to original form.
I tested Debug and Release version on few system and it seems ok.
I can also watch the test pass rate and we can take some action if we see occasional failures.

@wfurt
Copy link
Member Author

wfurt commented Jun 15, 2019

/azp run corefx-outerloop-linux

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@wfurt
Copy link
Member Author

wfurt commented Jun 16, 2019

System.IO.Tests failure is unrelated.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Address "System.Net.Sockets.SocketException: Address already in use" on K8S/Linux using HttpClient/TCP
5 participants