Correctly write single ByteBuf with memoryAddress
Motivation: While optimize gathering writes I introduced a bug when writing single ByteBuf that have a memoryAddress. This regression was introduced by 88bd6e7a9300073707f305409fa6481f1eeb2077. Modifications: Correctly use the writerIndex as argument when call Native.writeAddress(...) Result: No more corruption while write single buffers.
This commit is contained in:
parent
88bd6e7a93
commit
d5b7c131dd
@ -116,8 +116,9 @@ public final class EpollSocketChannel extends AbstractEpollChannel implements So
|
||||
if (buf.hasMemoryAddress()) {
|
||||
long memoryAddress = buf.memoryAddress();
|
||||
int readerIndex = buf.readerIndex();
|
||||
int writerIndex = buf.writerIndex();
|
||||
for (;;) {
|
||||
int localFlushedAmount = Native.writeAddress(fd, memoryAddress, readerIndex, readableBytes);
|
||||
int localFlushedAmount = Native.writeAddress(fd, memoryAddress, readerIndex, writerIndex);
|
||||
if (localFlushedAmount > 0) {
|
||||
writtenBytes += localFlushedAmount;
|
||||
if (writtenBytes == readableBytes) {
|
||||
@ -125,7 +126,6 @@ public final class EpollSocketChannel extends AbstractEpollChannel implements So
|
||||
break;
|
||||
}
|
||||
readerIndex += localFlushedAmount;
|
||||
readableBytes -= localFlushedAmount;
|
||||
} else {
|
||||
// Returned EAGAIN need to set EPOLLOUT
|
||||
setEpollOut();
|
||||
|
Loading…
x
Reference in New Issue
Block a user