This is an automated email from the ASF dual-hosted git repository.

lgoldstein pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mina-sshd.git


The following commit(s) were added to refs/heads/master by this push:
     new 4fa8f2c  [SSHD-1196] Provide configurable support for SFTP output 
stream chunking behavior
4fa8f2c is described below

commit 4fa8f2cbb8638e7f92cbfbc4b85fea644e6804ae
Author: Lyor Goldstein <lgoldst...@apache.org>
AuthorDate: Fri Aug 6 07:10:35 2021 +0300

    [SSHD-1196] Provide configurable support for SFTP output stream chunking 
behavior
---
 CHANGES.md                                                       | 1 +
 .../org/apache/sshd/common/channel/ChannelAsyncOutputStream.java | 2 +-
 .../src/main/java/org/apache/sshd/sftp/SftpModuleProperties.java | 9 +++++++++
 .../java/org/apache/sshd/sftp/client/impl/DefaultSftpClient.java | 4 +++-
 4 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md
index 47d6b2e..531127d 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -21,6 +21,7 @@
 ## Minor code helpers
 
 * [SSHD-1193](https://issues.apache.org/jira/browse/SSHD-1193) Provide a more 
user-friendly text in case disconnecting due to timeout(s).
+* [SSHD-1196](https://issues.apache.org/jira/browse/SSHD-1196) Provide 
configurable support for SFTP output stream chunking behavior.
 
 ## Behavioral changes and enhancements
 
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelAsyncOutputStream.java
 
b/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelAsyncOutputStream.java
index eb2d5c5..84fbf34 100644
--- 
a/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelAsyncOutputStream.java
+++ 
b/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelAsyncOutputStream.java
@@ -61,7 +61,7 @@ public class ChannelAsyncOutputStream extends 
AbstractCloseable implements IoOut
      *                                                       
SSH_MSG_CHANNEL_EXTENDED_DATA} indicating the output stream
      *                                                       type
      * @param sendChunkIfRemoteWindowIsSmallerThanPacketSize Determines the 
chunking behaviour, if the remote window
-     *                                                       size is smaller 
than the packet size. Can be use to
+     *                                                       size is smaller 
than the packet size. Can be used to
      *                                                       establish 
compatibility with certain clients, that wait
      *                                                       until the window 
size is 0 before adjusting it.
      * @see                                                  <A HREF=
diff --git 
a/sshd-sftp/src/main/java/org/apache/sshd/sftp/SftpModuleProperties.java 
b/sshd-sftp/src/main/java/org/apache/sshd/sftp/SftpModuleProperties.java
index 3144884..3303913 100644
--- a/sshd-sftp/src/main/java/org/apache/sshd/sftp/SftpModuleProperties.java
+++ b/sshd-sftp/src/main/java/org/apache/sshd/sftp/SftpModuleProperties.java
@@ -217,6 +217,15 @@ public final class SftpModuleProperties {
     public static final Property<Integer> SFTP_VERSION
             = SshServerConfigFileReader.SFTP_FORCED_VERSION_PROP;
 
+    /**
+     * Determines the chunking behaviour, if the remote window size is smaller 
than the packet size. Can be used to
+     * establish compatibility with certain clients, that wait until the 
window size is 0 before adjusting it.
+     *
+     * @see <A 
HREF="https://issues.apache.org/jira/browse/SSHD-1123";>SSHD-1123</A>
+     */
+    public static final Property<Boolean> CHUNK_IF_WINDOW_LESS_THAN_PACKET
+            = Property.bool("sftp-chunk-if-window-less-than-packet", false);
+
     private SftpModuleProperties() {
         throw new UnsupportedOperationException("No instance");
     }
diff --git 
a/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/impl/DefaultSftpClient.java
 
b/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/impl/DefaultSftpClient.java
index 1df279c..ae3f1c7 100644
--- 
a/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/impl/DefaultSftpClient.java
+++ 
b/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/impl/DefaultSftpClient.java
@@ -556,7 +556,9 @@ public class DefaultSftpClient extends AbstractSftpClient {
         }
 
         protected ChannelAsyncOutputStream createAsyncInput(Session session) {
-            return new ChannelAsyncOutputStream(this, 
SshConstants.SSH_MSG_CHANNEL_DATA) {
+            return new ChannelAsyncOutputStream(
+                    this, SshConstants.SSH_MSG_CHANNEL_DATA,
+                    
SftpModuleProperties.CHUNK_IF_WINDOW_LESS_THAN_PACKET.getRequired(session)) {
                 @SuppressWarnings("synthetic-access")
                 @Override
                 protected CloseFuture doCloseGracefully() {

Reply via email to