Adjust window on read
[netconf.git] / 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);