-
Notifications
You must be signed in to change notification settings - Fork 47
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
Conversation
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.
// 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() |
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 a scenario where we became writable but the partner wasn't set yet? This also goes for channelWritabilityChanged
.
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.
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.
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.
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.
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:
Result:
The SSH client example will be substantially more reliable.