Skip to content

Commit

Permalink
netty: record ByteBuf access in Netty{Client,Server}Stream before cal…
Browse files Browse the repository at this point in the history
…ling MessageDeframer (#6027)
  • Loading branch information
creamsoup committed Aug 2, 2019
1 parent 4e4d4d8 commit 4faad27
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion netty/src/main/java/io/grpc/netty/NettyClientStream.java
Expand Up @@ -174,7 +174,8 @@ public void operationComplete(ChannelFuture future) throws Exception {
private void writeFrameInternal(
WritableBuffer frame, boolean endOfStream, boolean flush, final int numMessages) {
Preconditions.checkArgument(numMessages >= 0);
ByteBuf bytebuf = frame == null ? EMPTY_BUFFER : ((NettyWritableBuffer) frame).bytebuf();
ByteBuf bytebuf =
frame == null ? EMPTY_BUFFER : ((NettyWritableBuffer) frame).bytebuf().touch();
final int numBytes = bytebuf.readableBytes();
if (numBytes > 0) {
// Add the bytes to outbound flow control.
Expand Down
2 changes: 1 addition & 1 deletion netty/src/main/java/io/grpc/netty/NettyServerStream.java
Expand Up @@ -150,7 +150,7 @@ private void writeFrameInternal(WritableBuffer frame, boolean flush, final int n
writeQueue.scheduleFlush();
return;
}
ByteBuf bytebuf = ((NettyWritableBuffer) frame).bytebuf();
ByteBuf bytebuf = ((NettyWritableBuffer) frame).bytebuf().touch();
final int numBytes = bytebuf.readableBytes();
// Add the bytes to outbound flow control.
onSendingBytes(numBytes);
Expand Down

0 comments on commit 4faad27

Please sign in to comment.