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

[SSHD-1173] Simplify writing in ChannelAsyncOutputStream #251

Merged
merged 1 commit into from Oct 13, 2022

Conversation

tomaswolf
Copy link
Member

Remove the option not to send a chunk when the remote window is smaller than the packet size, and we're trying to write more than the remote widow size bytes. This option may lead to hangs with peers that wait with sending their window adjustment until the window size is very low, or even zero.

RFC 4254 does not mandate any particular point at which an SSH implementation should send a window adjustment. Implementations doing so only once the window has been fully consumed are well within the bounds of the specification.

Therefore remove this option altogether, and always send some data if the window size is > 0. Refactor the writePacket() method to make it much simpler and clearer.

Client options removed:

  • SftpModuleProperties.CHUNK_IF_WINDOW_LESS_THAN_PACKET
  • CoreModuleProperties.ASYNC_SERVER_STDOUT_CHUNK_BELOW_WINDOW_SIZE
  • CoreModuleProperties.ASYNC_SERVER_STDERR_CHUNK_BELOW_WINDOW_SIZE
  • ChannelAsyncOutputStream(Channel, byte, boolean) constructor

These options were by default all false, potentially leading to hangs as described above. Already [SSHD-1123] had pointed out that problem, and bug [SSHD-1207] might also be caused by this. The feature was introduced in [SSHD-979] in commit e85b67e and later modified in commit 536d066.

@tomaswolf tomaswolf force-pushed the sshd-1173 branch 9 times, most recently from 21e0614 to fd15c71 Compare October 12, 2022 20:52
Remove the option not to send a chunk when the remote window is
smaller than the packet size, and we're trying to write more than
the remote window size bytes. This option may lead to hangs with
peers that wait with sending their window adjustment until the window
size is very low, or even zero.

RFC 4254 does not mandate any particular point at which an SSH
implementation should send a window adjustment. Implementations
doing so only once the window has been fully consumed are well
within the bounds of the specification.

Therefore remove this option altogether, and always send some data
if the window size is > 0. Refactor the writePacket() method to make
it much simpler and clearer.

Client options removed:

* SftpModuleProperties.CHUNK_IF_WINDOW_LESS_THAN_PACKET
* CoreModuleProperties.ASYNC_SERVER_STDOUT_CHUNK_BELOW_WINDOW_SIZE
* CoreModuleProperties.ASYNC_SERVER_STDERR_CHUNK_BELOW_WINDOW_SIZE
* ChannelAsyncOutputStream(Channel, byte, boolean) constructor

These options were by default all false, potentially leading to hangs
as described above. Already [SSHD-1123] had pointed out that problem,
and bug [SSHD-1207] might also be caused by this. The feature was
introduced in [SSHD-979] in commit e85b67e and later modified in
commit 536d066.

Also fix a race condition in WindowAdjustTest (unsynchronized access)
that made the test frequently hang because the write queue maintained
in that test got corrupted.
@tomaswolf tomaswolf merged commit 8cc9417 into apache:master Oct 13, 2022
@tomaswolf tomaswolf deleted the sshd-1173 branch November 2, 2022 22:39
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.

None yet

1 participant