diff --git a/src/main/java/io/netty/incubator/codec/quic/QuicheQuicChannel.java b/src/main/java/io/netty/incubator/codec/quic/QuicheQuicChannel.java index 1c32a68a0..88f58244f 100644 --- a/src/main/java/io/netty/incubator/codec/quic/QuicheQuicChannel.java +++ b/src/main/java/io/netty/incubator/codec/quic/QuicheQuicChannel.java @@ -261,7 +261,7 @@ boolean streamSendMultiple(long streamId, ByteBufAllocator allocator, ChannelOut res = streamSend(streamId, buffer, false); } - if (Quiche.throwIfError(res)) { + if (Quiche.throwIfError(res) || res == 0) { // stream has no capacity left stop trying to send. return false; } @@ -305,11 +305,10 @@ boolean streamRecv(long streamId, ByteBuf buffer) throws Exception { long memoryAddress = buffer.memoryAddress(); int recvLen = Quiche.quiche_conn_stream_recv(connectionAddressChecked(), streamId, memoryAddress + writerIndex, buffer.writableBytes(), finBuffer.memoryAddress()); - Quiche.throwIfError(recvLen); - boolean fin = finBuffer.getBoolean(writerIndex); - // Skip the FIN - buffer.setIndex(0, writerIndex + recvLen); - return fin; + if (!Quiche.throwIfError(recvLen)) { + buffer.setIndex(0, writerIndex + recvLen); + } + return finBuffer.getBoolean(0); } private void handleWriteEgress() { diff --git a/src/main/java/io/netty/incubator/codec/quic/QuicheQuicStreamChannel.java b/src/main/java/io/netty/incubator/codec/quic/QuicheQuicStreamChannel.java index 64b2c61e7..32a91d8f7 100644 --- a/src/main/java/io/netty/incubator/codec/quic/QuicheQuicStreamChannel.java +++ b/src/main/java/io/netty/incubator/codec/quic/QuicheQuicStreamChannel.java @@ -305,6 +305,7 @@ void recv() { allocHandle.reset(config); ByteBuf byteBuf = null; boolean close = false; + boolean readCompleteNeeded = false; QuicheQuicChannel parent = parentQuicChannel(); try { do { @@ -317,12 +318,15 @@ void recv() { break; } readPending = false; + readCompleteNeeded = true; pipeline.fireChannelRead(byteBuf); byteBuf = null; } while (allocHandle.continueReading() && !close); allocHandle.readComplete(); - pipeline.fireChannelReadComplete(); + if (readCompleteNeeded) { + pipeline.fireChannelReadComplete(); + } if (close) { closeOnRead(pipeline); }