fengjiajie commented on a change in pull request #166:
URL: https://github.com/apache/mina-sshd/pull/166#discussion_r487798281
##########
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:
Maybe this threshold can be configured?
when maxBufferSize = 1MB, I think ```if (total <= 500KB)``` might be better
for performance? to avoid frequent suspensions and resumptions
inFlightDataSize > 1 MB, suspendRead
inFlightDataSize < 0.5 MB, resumedRead
----------------------------------------------------------------
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]