-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Socket: delete unix local endpoint filename on Close #52103
Conversation
Tagging subscribers to this area: @dotnet/ncl Issue DetailsFixes #45537 @antonfirsov @geoffkizer ptal
|
I just realized relative paths need specific handling. The working directory may change between the time of |
should the file be deleted only if created by .NET ? ... or is it always the case e.g. the local endpoint is transient? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
The file is created when the socket is bound. If the file is already there, the socket will fail to bind. |
// correct type (IPEndPoint, etc). The Bind operation sets _rightEndPoint. Other operations must only set | ||
// it when the value is still null. | ||
// This enables tracking the file created by UnixDomainSocketEndPoint when the Socket is bound, | ||
// and to delete that file when the Socket gets disposed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I avoided adding a field to Socket
for the stake of tracking the file to be deleted. Instead this is tracked through _rightEndPoint
UnixDomainSocketEndPoint.BoundFileName
.
On Bind an instance is created that has this property set. And on dispose, the file then gets deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've wondered this for a while... what does the "right" part of the name mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just guessing: right type. The name is not very clear. Maybe we should change it to _typedEndpoint
or _endpointType
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I keep asking this question every time I see that variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really know either. Would love to understand.
It might be "right" in the sense that it's the result after resolving wildcards like port=0. Does that seem right?
src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs
Outdated
Show resolved
Hide resolved
@antonfirsov @geoffkizer can you continue reviewing this? |
@tmds the |
Triage: @tmds can you please remove endpoint optimization from this change? We can make it separate PR and discuss there if and how we want it to behave. |
I need to look at the CI failures, they seem related to the change.
The discussion is more about #39313 than it is about this PR. Can we remove the optimization if it is decided to revert that PR? It will then happen as part of removing the |
@tmds we are undecided yet re reverting
I can't see the failures, I assume it was outerloop which disappeared from the log, will rerun those tests. |
/azp run runtime-libraries-coreclr outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
The concern isn't about how this PR uses |
src/libraries/System.Net.Sockets/src/System/Net/Sockets/UnixDomainSocketEndPoint.cs
Show resolved
Hide resolved
src/libraries/System.Net.Sockets/tests/FunctionalTests/UnixDomainSocketTest.cs
Outdated
Show resolved
Hide resolved
…that fails on Windows
@@ -284,7 +287,7 @@ public int Available | |||
{ | |||
// Update the state if we've become connected after a non-blocking connect. | |||
_isConnected = true; | |||
_rightEndPoint = _nonBlockingConnectRightEndPoint; | |||
_rightEndPoint ??= _nonBlockingConnectRightEndPoint; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In what situation will it be non-null? I'm wondering in what situation we previously would have overwritten it and now we won't...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't think about this much. I replaced everything with a conditional assignment except for the one in Bind
.
It can be non-null if for example you Bind
first, and then do a Connect
and then call LocalEndPoint
and end up in this branch.
We don't want to overwrite it because that will lose the tracking (via _rightEndPoint
) of the unix socket file we need to delete.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it would make sense to add a test for this case, so we don't break it in the future. Scratch it would be too difficult because of timing.
…sUnixDomainSockets condition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good after fixing the test (https://github.com/dotnet/runtime/pull/52103/files#r638644278) and answering https://github.com/dotnet/runtime/pull/52103/files#r638385763 (missed the answer).
/azp run runtime-libraries-coreclr outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. CI failures are unrelated build failures.
… ConditionalFact attributes.
…asm_debugger_and_use_debugger_agent * upstream/main: (597 commits) Fix42292 (dotnet#52463) [mono] Remove some obsolete emscripten flags. (dotnet#53486) Fixed path to projects (dotnet#53435) support ServerCertificateContext in quic (dotnet#53175) Socket: delete unix local endpoint filename on Close (dotnet#52103) [mono] Fix sgen_gc_info.memory_load_bytes (dotnet#53364) Refactor MsQuic's native IP address types. (dotnet#53461) Re-enabled optimizations for gtFoldExprConst (dotnet#53347) Add diagnostic support into sample app and AppBuilders on Mono. (dotnet#53361) Fix issues with virtuals and mdarrays (dotnet#53400) Split Variant marshalling tests (dotnet#53035) Update clrjit.natvis to cover GT_SIMD and GT_HWINTRINSIC (dotnet#53470) remove WSL checks in tests (dotnet#53475) Always spawn message loop thread for SystemEvents (dotnet#53467) add AcceptAsync cancellation overloads (dotnet#53340) Remove unnecessary reference to iOS workload pack in the Mono workload (dotnet#53425) Add CookieContainer.GetAllCookies (dotnet#53441) Remove DynamicallyAccessedMembers on JsonSerializer (dotnet#53235) [wasm] Re-enable Wasm.Build.Tests (dotnet#53433) [libraries] Move library tests Feature Switches defaults to Functional tests (dotnet#53253) ...
Fixes #45537
@antonfirsov @geoffkizer ptal