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

Resolve stalls in the example client. #52

Merged
merged 4 commits into from
Nov 20, 2020

Conversation

Lukasa
Copy link
Collaborator

@Lukasa Lukasa commented Nov 20, 2020

Motivation:

When running the example client on extremely low latency connections it
can occasionally stall, printing nothing to stdout before exiting. This
is the result of a timing window where we receive the data before the
pipe bootstrap has been configured and our glue handlers are not in
place.

There is also another timing window where we block reads on the SSH
Child Channel because the glue handler asked if the partner was writable
before the partner was inserted into the pipe channel.

Modifications:

  • Cleanup both timing windows.

Result:

The SSH client example will be substantially more reliable.

Motivation:

When running the example client on extremely low latency connections it
can occasionally stall, printing nothing to stdout before exiting. This
is the result of a timing window where we receive the data before the
pipe bootstrap has been configured and our glue handlers are not in
place.

There is also another timing window where we block reads on the SSH
Child Channel because the glue handler asked if the partner was writable
before the partner was inserted into the pipe channel.

Modifications:

- Cleanup both timing windows.

Result:

The SSH client example will be substantially more reliable.
@Lukasa Lukasa added the patch-version-bump-only For PRs that when merged will only cause a bump of the patch version, ie. 1.0.x -> 1.0.(x+1) label Nov 20, 2020
@Lukasa Lukasa requested a review from Joannis November 20, 2020 16:07
// It's possible our partner asked if we were writable, before, and we couldn't answer.
// Consider updating it.
if context.channel.isWritable {
self.partner?.partnerBecameWritable()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a scenario where we became writable but the partner wasn't set yet? This also goes for channelWritabilityChanged.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Seeing the current usages, and the fact that the class is internal, I think it's never going to happen. So it might be wise to make it implicitly unwrapped.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In principle the partner should always be set, but we do nil it out explicitly on handlerRemoved so it’s likely better safe than sorry here.

@Lukasa Lukasa merged commit 5cb7848 into apple:main Nov 20, 2020
@Lukasa Lukasa deleted the cb-resolve-stall-in-example-client branch November 20, 2020 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch-version-bump-only For PRs that when merged will only cause a bump of the patch version, ie. 1.0.x -> 1.0.(x+1)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants