Use correct writerIndex when read for channel
This commit is contained in:
parent
9330172f80
commit
728417abd5
@ -502,10 +502,11 @@ public final class EpollSocketChannel extends AbstractEpollChannel implements So
|
|||||||
* Read bytes into the given {@link ByteBuf} and return the amount.
|
* Read bytes into the given {@link ByteBuf} and return the amount.
|
||||||
*/
|
*/
|
||||||
private int doReadBytes(ByteBuf byteBuf) throws Exception {
|
private int doReadBytes(ByteBuf byteBuf) throws Exception {
|
||||||
ByteBuffer buf = byteBuf.internalNioBuffer(0, byteBuf.writableBytes());
|
int writerIndex = byteBuf.writerIndex();
|
||||||
|
ByteBuffer buf = byteBuf.internalNioBuffer(writerIndex, byteBuf.writableBytes());
|
||||||
int localReadAmount = Native.read(fd, buf, buf.position(), buf.limit());
|
int localReadAmount = Native.read(fd, buf, buf.position(), buf.limit());
|
||||||
if (localReadAmount > 0) {
|
if (localReadAmount > 0) {
|
||||||
byteBuf.writerIndex(byteBuf.writerIndex() + localReadAmount);
|
byteBuf.writerIndex(writerIndex + localReadAmount);
|
||||||
}
|
}
|
||||||
return localReadAmount;
|
return localReadAmount;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user