Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 Socket.DuplicateAndClose() for Windows #1858
Implement Socket.DuplicateAndClose() for Windows #1858
Changes from 10 commits
52dc552
5b617e6
bee3140
34bf608
fe81eeb
23fdf75
a0ff6f3
3d801cc
54df6d9
7ea829a
170c182
6d9d5af
b3306ba
b52c214
ab6004b
502619f
9a476af
4b0ccb2
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Is there any potential difference in the handling of different address families? Wondering if we need tests for IPv6 sockets as well, or if Windows doesn't discriminate and a test for IPv4 sockets will be sufficient.
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.
To me it looks quite arbitrary whether a functionality is also tested against IPV6 in socket test code. I added a few IPV6 test cases for the duplication to make sure it is covered. See the parameters of
DuplicateAndClose_TcpServerHandler
which is emulating most common user scenario.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.
Won't we get an ArgumentException as well if the handle wasn't opened for overlapped I/O? We're assuming that's the case then?
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 made this based this on my understanding of the code in
ClrThreadPoolBoundHandle.Windows.cs
:runtime/src/coreclr/src/System.Private.CoreLib/src/System/Threading/ClrThreadPoolBoundHandle.Windows.cs
Lines 30 to 34 in 6ed4a5e
I assume that the handle can not be invalid since we checked it before. Based on the comment, and the exception message, the only other possible reason is: "Handle already bound or sync handle". Let me know, if I'm missing something!
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.
Do we use this style of commenting elsewhere in System.Net.Sockets, with a blank comment line above and below? We've generally moved away from that elsewhere.
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.
Occasionally yes, it was was used in the methods I changed. Getting rid of it.
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 dispose of state here that may have been created, namely the _handle. Even if it's invalid, it'll likely still trigger finalization. Probably want to null it out as well.
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.
This looks like an unnecessary check, since
SocketPal.CreateSocket
already validates handle. Added the disposal there, getting rid of this branch here.