Skip to content
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

Do not half-close outbound channel on graceful client closure #1111

Merged
merged 1 commit into from
Jul 31, 2020

Conversation

idelpivnitskiy
Copy link
Member

Motivation:

When client observes users request to close the connection gracefully it
shutdowns the output channel if the in-flight request is already written,
then awaits for the incoming response to close the full channel.
Some servers interpret FIN from the half-closed client as an indicator that
it lost interest in their data and therefore, server may closes the second
half of the connection asap. As the result, connection may be closed before
client receives the full response from the server.

Modifications:

  • Reproduce this scenario using a simple proxy tunnel that does not support
    half-closed connections;
  • Close the proxy tunnel when it sees EOF or an error to propagate closure
    to the other side of the tunnel;
  • Defer connection closure on the client-side until it completes the full
    request-response iteration and connection becomes idle;
  • Add more tests to verify that client handles graceful closure correctly
    at any state of in-flight request-response processing;

Result:

In-flight responses are not aborted when client closes gracefully.

Motivation:

When client observes users request to close the connection gracefully it
shutdowns the output channel if the in-flight request is already written,
then awaits for the incoming response to close the full channel.
Some servers interpret FIN from the half-closed client as an indicator that
it lost interest in their data and therefore, server may closes the second
half of the connection asap. As the result, connection may be closed before
client receives the full response from the server.

Modifications:

- Reproduce this scenario using a simple proxy tunnel that does not support
half-closed connections;
- Close the proxy tunnel when it sees EOF or an error to propagate closure
to the other side of the tunnel;
- Defer connection closure on the client-side until it completes the full
request-response iteration and connection becomes idle;
- Add more tests to verify that client handles graceful closure correctly
at any state of in-flight request-response processing;

Result:

In-flight responses are not aborted when client closes gracefully.
Copy link
Collaborator

@NiteshKant NiteshKant left a comment

Choose a reason for hiding this comment

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

This change LGTM but should the half-closure be removed for server side too?

@idelpivnitskiy
Copy link
Member Author

@NiteshKant yes, we should. Server-side change is coming soon

@idelpivnitskiy idelpivnitskiy merged commit c993229 into apple:main Jul 31, 2020
@idelpivnitskiy idelpivnitskiy deleted the client-graceful-close branch July 31, 2020 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants