gnodet commented on a change in pull request #166:
URL: https://github.com/apache/mina-sshd/pull/166#discussion_r487826081



##########
File path: 
sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
##########
@@ -217,9 +225,23 @@ public void messageReceived(IoSession session, Readable 
message) throws Exceptio
                         log.debug("doInit({}) Ignoring write to channel in 
CLOSING state", TcpipServerChannel.this);
                     }
                 } else {
-                    Buffer buffer = new ByteArrayBuffer(message.available(), 
false);
+                    int length = message.available();
+                    Buffer buffer = new ByteArrayBuffer(length, false);
                     buffer.putBuffer(message);
-                    out.writePacket(buffer);
+                    long total = inFlightDataSize.addAndGet(length);
+                    if (total > maxBufferSize) {
+                        session.suspendRead();
+                    }
+                    IoWriteFuture ioWriteFuture = out.writePacket(buffer);
+                    ioWriteFuture.addListener(new 
SshFutureListener<IoWriteFuture>() {
+                        @Override
+                        public void operationComplete(IoWriteFuture future) {
+                            long total = inFlightDataSize.addAndGet(-length);
+                            if (total <= maxBufferSize) {

Review comment:
       Right, that makes sense, I'll split the property.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to