Http2ConnectionHandler not flushing on writabilityChange
Motivation: The Http2ConnectionHandler was writing pending bytes, but was not flushing. This may result in deadlock. Modifications: - Http2ConnectionHandler must writePendingBytes and also flush. Result: Data is now flushed after writabilityChange writes more data to underlying layers.
This commit is contained in:
parent
7b4bdebfd4
commit
d488767e72
@ -167,7 +167,7 @@ public class Http2ConnectionHandler extends ByteToMessageDecoder implements Http
|
|||||||
@Override
|
@Override
|
||||||
public void flush(ChannelHandlerContext ctx) throws Http2Exception {
|
public void flush(ChannelHandlerContext ctx) throws Http2Exception {
|
||||||
// Trigger pending writes in the remote flow controller.
|
// Trigger pending writes in the remote flow controller.
|
||||||
connection().remote().flowController().writePendingBytes();
|
encoder.flowController().writePendingBytes();
|
||||||
try {
|
try {
|
||||||
super.flush(ctx);
|
super.flush(ctx);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
@ -396,11 +396,14 @@ public class Http2ConnectionHandler extends ByteToMessageDecoder implements Http
|
|||||||
public void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception {
|
public void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception {
|
||||||
// Writability is expected to change while we are writing. We cannot allow this event to trigger reentering
|
// Writability is expected to change while we are writing. We cannot allow this event to trigger reentering
|
||||||
// the allocation and write loop. Reentering the event loop will lead to over or illegal allocation.
|
// the allocation and write loop. Reentering the event loop will lead to over or illegal allocation.
|
||||||
|
try {
|
||||||
if (ctx.channel().isWritable()) {
|
if (ctx.channel().isWritable()) {
|
||||||
encoder.flowController().writePendingBytes();
|
flush(ctx);
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
super.channelWritabilityChanged(ctx);
|
super.channelWritabilityChanged(ctx);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
|
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
|
||||||
|
Loading…
Reference in New Issue
Block a user