Skip to content

Commit

Permalink
DefaultHttp2ConnectionDecoder write ping buffer
Browse files Browse the repository at this point in the history
Motivation:
DefaultHttp2ConnectionDecoder writes a ACK when receiving a ping frame and sends the same data buffer it received. The data buffer is also passed to the listener, but the indexes are shared between the send and the listener. We should ensure the indexes are independent for these two operations.

Modifications:
- Call slice on the buffer that is being sent

Result:
Listener now has access to a buffer that will not appear to be already consumed.
  • Loading branch information
Scottmitch committed Oct 2, 2015
1 parent 92985ee commit 24bf367
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ public void onSettingsRead(ChannelHandlerContext ctx, Http2Settings settings) th
public void onPingRead(ChannelHandlerContext ctx, ByteBuf data) throws Http2Exception {
// Send an ack back to the remote client.
// Need to retain the buffer here since it will be released after the write completes.
encoder.writePing(ctx, true, data.retain(), ctx.newPromise());
encoder.writePing(ctx, true, data.slice().retain(), ctx.newPromise());

listener.onPingRead(ctx, data);
}
Expand Down

0 comments on commit 24bf367

Please sign in to comment.