Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

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

Merged
wfurt merged 2 commits into
dotnet:masterfrom
wfurt:socket_finalize_37044
Jun 16, 2019
Merged

wfurt merged 2 commits into
dotnet:masterfrom
wfurt:socket_finalize_37044

Conversation

@wfurt

@wfurt wfurt commented Jun 13, 2019 •

Copy link
Copy Markdown
Member

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 stephentoub and tmds June 13, 2019 09:23
@wfurt wfurt self-assigned this Jun 13, 2019
@wfurt

wfurt commented Jun 13, 2019

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 4 pipeline(s).

@tmds tmds left a comment

Copy link
Copy Markdown
Member

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

wfurt commented Jun 14, 2019

Copy link
Copy Markdown
Member Author

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

wfurt commented Jun 15, 2019

Copy link
Copy Markdown
Member Author

/azp run corefx-outerloop-linux

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@wfurt

wfurt commented Jun 16, 2019

Copy link
Copy Markdown
Member Author

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