gnodet commented on a change in pull request #166:
URL: https://github.com/apache/mina-sshd/pull/166#discussion_r490244112
##########
File path:
sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Session.java
##########
@@ -382,7 +385,32 @@ protected void handleReadCycleFailure(ByteBuffer buffer,
Readable bufReader, Thr
exceptionCaught(exc);
}
+ @Override
+ public void suspendRead() {
+ log.trace("suspendRead({})", this);
+ if (suspendRead.compareAndSet(false, true)) {
+ log.debug("suspendRead({}) requesting read suspension", this);
+ }
+ }
+
+ @Override
+ public void resumeRead() {
+ log.trace("resumeRead({})", this);
+ Runnable runnable = readRunnable.getAndSet(null);
+ suspendRead.set(false);
+ if (runnable != null) {
+ log.debug("resumeRead({}) resuming read", this);
+ runnable.run();
+ }
+ }
+
protected void doReadCycle(ByteBuffer buffer,
Nio2CompletionHandler<Integer, Object> completion) {
+ if (suspendRead.get()) {
+ log.debug("doReadCycle({}) suspending reading", this);
+ readRunnable.set(() -> doReadCycle(buffer, completion));
+ return;
+ }
+
Review comment:
Nice catch, i've pushed a new commit with a synchronized block to avoid
that.
----------------------------------------------------------------
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]