Fix the regression caused by f31c630c8cc15c4de1cc7e45b6c5c8053d5bcb75
f31c630c8cc15c4de1cc7e45b6c5c8053d5bcb75 was causing SocketGatheringWriteTest to fail because it does not take the case where an empty buffer exists in a gathering write. When there is an empty buffer in a gathering write, the number of buffers returned by ChannelOutboundBuffer.nioBuffer() and the actual number of write attemps can differ. To remove the write requests correctly, a byte transport must use ChannelOutboundBuffer.removeBytes()
This commit is contained in:
parent
2bd7a8387d
commit
e3d6d8e561
@ -297,22 +297,11 @@ public class NioSocketChannel extends AbstractNioByteChannel implements io.netty
|
||||
break;
|
||||
}
|
||||
|
||||
if (done) {
|
||||
// Release all written buffers.
|
||||
//
|
||||
// It's important to loop only over nioBufferCnt as there may be other messages in the
|
||||
// ChannelOutboundBuffer that are not of type ByteBuf and so was not included for gathering-write.
|
||||
//
|
||||
// See https://github.com/netty/netty/issues/2769
|
||||
for (int i = nioBufferCnt; i > 0; i --) {
|
||||
final ByteBuf buf = (ByteBuf) in.current();
|
||||
in.progress(buf.readableBytes());
|
||||
in.remove();
|
||||
}
|
||||
} else {
|
||||
// Did not write all buffers completely.
|
||||
// Release the fully written buffers and update the indexes of the partially written buffer.
|
||||
// Release the fully written buffers, and update the indexes of the partially written buffer.
|
||||
in.removeBytes(writtenBytes);
|
||||
|
||||
if (!done) {
|
||||
// Did not write all buffers completely.
|
||||
incompleteWrite(setOpWrite);
|
||||
break;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user