From 7a375a492c08deee6ead242e03f4ecd694598993 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Fri, 16 Aug 2019 09:27:47 +0200 Subject: [PATCH] HTTP2: Update local flow-controller on Channel.read() if needed (#9400) Motivation: We should better update the flow-controller on Channel.read() to reduce overhead and memory overhead. See https://github.com/netty/netty/pull/9390#issuecomment-513008269 Modifications: Move updateLocalWindowIfNeeded() to doBeginRead() Result: Reduce memory overhead --- .../netty/handler/codec/http2/AbstractHttp2StreamChannel.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/AbstractHttp2StreamChannel.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/AbstractHttp2StreamChannel.java index 5b4e342f85..6ccff12288 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/AbstractHttp2StreamChannel.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/AbstractHttp2StreamChannel.java @@ -751,6 +751,8 @@ abstract class AbstractHttp2StreamChannel extends DefaultAttributeMap implements if (!isActive()) { return; } + updateLocalWindowIfNeeded(); + switch (readStatus) { case IDLE: readStatus = ReadStatus.IN_PROGRESS; @@ -827,8 +829,6 @@ abstract class AbstractHttp2StreamChannel extends DefaultAttributeMap implements readStatus = ReadStatus.IDLE; } - updateLocalWindowIfNeeded(); - allocHandle.readComplete(); pipeline().fireChannelReadComplete(); if (config().isAutoRead()) {