You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If i have a DIRECT byteBuf to write to two channels, and i forgot to slice or duplicate when write, because of the using of internalNioBuffer, the two channels (or two channel's eventloops) use the SAMEByteBuf's ByteBuffer, this will cause many problems.
E.g.
When the first eventLoop thread try to write the ByteBuf to socket but not start, and then, the second eventLoop thread start write the same ByteBuf and succeed, and then the first eventLoop thread resume, but when it write, the ByteBuf's ByteBuffer has no writable bytes, because the second eventLoop thread has already written it.
Now, for the first eventLoop thread, the ByteBuf's readerIndex is unmodified, so it think the ByteBuf has writable bytes, but the ByteBuf's ByteBuffer's position already reach it's limit, no writables bytes, so the eventLoop thread will try to write the ByteBuf, but write nothing, and then try again, and then write nothing, enter an endless loop...
The text was updated successfully, but these errors were encountered:
But if using internalNioBuffer, there's a chance to lead to EventLoop thread enter endless loop, is't too dangerous ?
After I‘v read the code, I have another question.
If I write a HeapByteBuf, netty will copy it to a DirectByteBuf, and if I write a DirectByteBuf, netty will use it,
then netty will write these DirectByteBufs to socket.
In this process, internalNioBuffer will be used in some setBytes methods, e.g. this, but why these setBytes methods use internalNioBuffer method instead of using buffer directly ? Perhaps for DirectByteBuf, internalNioBuffer method should return buffer instead of the cached one ? Perhaps for DirectByteBuf, the cached one is unnecessary ?
Hi guys,
Why ChannelOutboundBuffer.nioBuffers() use internalNioBuffer instead of nioBuffer ?
If i have a DIRECT byteBuf to write to two channels, and i forgot to slice or duplicate when write, because of the using of internalNioBuffer, the two channels (or two channel's eventloops) use the SAME ByteBuf's ByteBuffer, this will cause many problems.
E.g.
When the first eventLoop thread try to write the ByteBuf to socket but not start, and then, the second eventLoop thread start write the same ByteBuf and succeed, and then the first eventLoop thread resume, but when it write, the ByteBuf's ByteBuffer has no writable bytes, because the second eventLoop thread has already written it.
Now, for the first eventLoop thread, the ByteBuf's readerIndex is unmodified, so it think the ByteBuf has writable bytes, but the ByteBuf's ByteBuffer's position already reach it's limit, no writables bytes, so the eventLoop thread will try to write the ByteBuf, but write nothing, and then try again, and then write nothing, enter an endless loop...
The text was updated successfully, but these errors were encountered: