-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Implement Equals & GetHashCode for LingerOption - fix Socket outerloop tests #78747
Conversation
Tagging subscribers to this area: @dotnet/ncl Issue DetailsThis is regression from #74645 & #73499
macOS additionally fails with exception as some of the gutters are not supported
with this I can run tests with
|
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!
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.
We should rename the PR, and it would be nice to understand better what is going wrong in the original variant. Looks good otherwise.
src/libraries/System.Net.Sockets/src/System/Net/Sockets/LingerOption.cs
Outdated
Show resolved
Hide resolved
object? origValue = pi.GetValue(source); | ||
object? cloneValue = pi.GetValue(this); | ||
|
||
Debug.Assert(Equals(origValue, cloneValue), $"{pi.Name}. Expected: {origValue}, Actual: {cloneValue}"); |
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.
It is very weird that Equals(origValue, cloneValue) == false
for LingerOption
on Unix only. They should be equal by reference regardless of the platform.
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 @liveans knows the answer? Part of the difference is that Windows support Accept from socket natively while on Unix we construct it behind the scenes.
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 just realized that, when we create a new SafeSocketHandle
for this purpose, we're not replacing public
properties, we're just replacing private
variables, that can be root cause of the issue. I'm going to raise a PR for this.
Edit: It turns out that wasn't the problem, but we need Equals
function anyway, because we're creating new instance for LingerOption
everytime we try to get value from LingerState
.
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.
After this PR gets merged, I'll open a PR for transferring handle
state between temporary and new handle
s for this case, as we already did here in ReplaceHandle
method:
runtime/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.Unix.cs
Lines 160 to 169 in d104e34
if (_handle.IsTrackedOption(TrackedSocketOptions.DualMode)) DualMode = _handle.DualMode; | |
if (_handle.IsTrackedOption(TrackedSocketOptions.DontFragment)) DontFragment = dontFragment; | |
if (_handle.IsTrackedOption(TrackedSocketOptions.EnableBroadcast)) EnableBroadcast = broadcast; | |
if (_handle.IsTrackedOption(TrackedSocketOptions.LingerState)) LingerState = linger!; | |
if (_handle.IsTrackedOption(TrackedSocketOptions.NoDelay)) NoDelay = noDelay; | |
if (_handle.IsTrackedOption(TrackedSocketOptions.ReceiveBufferSize)) ReceiveBufferSize = receiveSize; | |
if (_handle.IsTrackedOption(TrackedSocketOptions.ReceiveTimeout)) ReceiveTimeout = receiveTimeout; | |
if (_handle.IsTrackedOption(TrackedSocketOptions.SendBufferSize)) SendBufferSize = sendSize; | |
if (_handle.IsTrackedOption(TrackedSocketOptions.SendTimeout)) SendTimeout = sendTimeout; | |
if (_handle.IsTrackedOption(TrackedSocketOptions.Ttl)) Ttl = ttl; |
src/libraries/System.Net.Sockets/src/System/Net/Sockets/LingerOption.cs
Outdated
Show resolved
Hide resolved
…Option.cs Co-authored-by: Miha Zupan <[email protected]>
/azp run runtime-libraries-coreclr outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run runtime-libraries-coreclr outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
Outerloop seems to be broken, innerloop failure is #69101 |
This is regression from #74645 & #73499
On Linux and macOS the test fail on Debug Assert
macOS additionally fails with exception as some of the gutters are not supported
with this I can run tests with
/p:outerloop=true
once again on Unix