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

Revert "Socket: Linux: unblock synchronous socket operations on Dispose"#38764

Merged
davidsh merged 1 commit intomasterfrom
revert-37486-linux_unblock_socket
Jun 21, 2019
Merged

Revert "Socket: Linux: unblock synchronous socket operations on Dispose"#38764
davidsh merged 1 commit intomasterfrom
revert-37486-linux_unblock_socket

Conversation

@davidsh
Copy link
Contributor

@davidsh davidsh commented Jun 21, 2019

Reverts #37486

@davidsh davidsh added os-linux Linux OS (any supported distro) area-System.Net.Sockets labels Jun 21, 2019
@davidsh davidsh added this to the 3.0 milestone Jun 21, 2019
@davidsh davidsh self-assigned this Jun 21, 2019
@davidsh davidsh requested review from a team and stephentoub June 21, 2019 21:53
@davidsh
Copy link
Contributor Author

davidsh commented Jun 21, 2019

@wfurt has done an analysis and it seems that this PR has unintentionally affected async Socket I/O. There are cases where it causes RST instead of FIN to be sent. A full write-up will be forthcoming. See analysis #38765.

For now, we are going to revert this PR.

cc: @tmds

@davidsh
Copy link
Contributor Author

davidsh commented Jun 21, 2019

/azp run

@davidsh
Copy link
Contributor Author

davidsh commented Jun 21, 2019

cc: @krwq @wtgodbe

@azure-pipelines
Copy link

Azure Pipelines successfully started running 4 pipeline(s).

Copy link
Member

@wfurt wfurt left a comment

Choose a reason for hiding this comment

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

LGTM.

@krwq
Copy link
Member

krwq commented Jun 21, 2019

Would it make sense to iteratively do fixes to that PR instead of reverting? Most of the changes in that PR look good and have rather positive impact on the stability

@stephentoub
Copy link
Member

Given that we're about to ship Preview 7, I agree we should revert. We can try again after Preview 7 if we believe we've really nailed the problems.

@krwq
Copy link
Member

krwq commented Jun 21, 2019

fair enough

@wfurt
Copy link
Member

wfurt commented Jun 21, 2019

I went back to the original PR and there are notes abut aborting. So I think that part was at least partially intended.I think we just need to be more careful about compat. It seems like it has potential to cause troubles.

@davidsh davidsh merged commit 42ecf71 into master Jun 21, 2019
@davidsh davidsh deleted the revert-37486-linux_unblock_socket branch June 21, 2019 23:51
@tmds
Copy link
Member

tmds commented Jun 22, 2019

I went back to the original PR and there are notes abut aborting. So I think that part was at least partially intended.I think we just need to be more careful about compat. It seems like it has potential to cause troubles.

Yes, the changes were intentional and should make Linux behave similar to Windows.
@wfurt @davidsh Do we know scenarios where a RST is now being sent where that was not the case with the same code on Windows?

Would it make sense to iteratively do fixes to that PR instead of reverting?

This would have been my preference.

@wfurt
Copy link
Member

wfurt commented Jun 22, 2019

since the aim was to unblock blocking synchronous calls, why does that change Async path as well? That never had issue closing sockets.

@tmds
Copy link
Member

tmds commented Jun 22, 2019

The tests run both on the sync and async apis, and assert Windows behavior. To make tests pass, changes were also make to async paths.

@wfurt
Copy link
Member

wfurt commented Jun 23, 2019

I think timing was not good as we saw new test failures on Linux and behavior change on Linux while marching towards preview cutoff on Monday.

The PR end up doing way more than the title claimed or what linked issues referred to.

I did little bit more testing and you are correct that it does match Windows better. I don't know about timing and buffering but it does at least with sending RST.

I think it makes Socket use more difficult requiring more steps to close properly and it will bite Unix developers as this was never needed on Linux (and some applications still may depend on) but it does match our documentation.
https://docs.microsoft.com/en-us/dotnet/api/system.net.sockets.socket.close?view=netcore-2.2

Perhaps we should restore conversation about the behavior next week. It seems like this change brings:

  • unblock synchronous calls on Dispose (I verified it now works)
  • uses SafeHandle instead of IntPtr as general improvement
  • tries to match Windows and sends RST on Close without shutdown and/or fiddling with Linger options.

cc: @geoffkizer

@davidsh
Copy link
Contributor Author

davidsh commented Jun 23, 2019

We reverted this PR because after it was merged we started seeing test failures across both Linux and Windows, sync and async. We are preparing for Preview 7 and we need to stabilize for that.

The intent of the original PR was to make Linux sync socket behavior behavior especially regarding cancellation. But the PR went beyond that in the end and affected async behaviors and Windows.

If we want to consider these kind of changes in the future, it would be better to have smaller, more defined, PRs.

@tmds
Copy link
Member

tmds commented Jun 23, 2019

We are preparing for Preview 7 and we need to stabilize for that.

I understand.

But the PR went beyond that in the end and affected async behaviors and Windows.

This happened based on review comments, and the sum was needed to validate consistent xplat behavior.

@krwq
Copy link
Member

krwq commented Jun 24, 2019

@tmds, we just need to do a bit more validation with this which we don't have enough time for until after preview 7.

steveharter pushed a commit to steveharter/dotnet_corefx that referenced this pull request Jun 25, 2019
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-System.Net.Sockets os-linux Linux OS (any supported distro)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants