Adjust window on read 81/89781/2
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 14 May 2020 21:09:03 +0000 (23:09 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 15 May 2020 09:11:20 +0000 (11:11 +0200)
As a side-effect of us bypassing the read function, we no longer
update the window occupancy, which leads to the other side stopping
sending data. Make sure we adjust the window after passing the data
down the pipeline.

JIRA: NETCONF-686
Change-Id: I66c4873d901f7b88aabd97a1c599be64397b16c7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/client/NettyAwareChannelSubsystem.java

index 5df448b0a87c64aaa0a90efd540f01b518dd054b..035bbdcba04f9ed71485e1a5419fc56bbafe90e9 100644 (file)
@@ -37,6 +37,7 @@ public class NettyAwareChannelSubsystem extends ChannelSubsystem {
         if (!isClosing()) {
             // TODO: consider using context's allocator for heap buffer here
             ctx.fireChannelRead(Unpooled.copiedBuffer(data, off, (int) len));
+            adjustWindow(len);
         }
     }
 
@@ -45,9 +46,14 @@ public class NettyAwareChannelSubsystem extends ChannelSubsystem {
         // If we're already closing, ignore incoming data
         if (!isClosing()) {
             LOG.debug("Discarding {} bytes of extended data", len);
+            adjustWindow(len);
         }
     }
 
+    private void adjustWindow(final long len) throws IOException {
+        getLocalWindow().consumeAndCheck(len);
+    }
+
     @Override
     public void close() {
         this.close(false);