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
The logic ReadableChannelWrapper::read expects to have the buffer filled in its entirety in one go since it will call consumers with the buffer flipped (so it reports the remaining counter as the total amount read).
Consider an incoming InputStream that is not file-system based (say, nfs or incoming from socket) and may not fill the entire buffer (which has an expected size) in one read:
Suppose buffer is allocated with 100 and first read call fills it with 30.
In the case we observed consumers are now called with buffer.duplicate().flip() which will report 30 as as its remaining().
we had a 'byte counting' consumer (inited with ReadableChannelWrapper::start) which simply has the logic count += buffer.remaining()
so count is now at 30.
Suppose next read gets another 20.
Now buffer.remaining() == 50 so count += buffer.remaining() --> 80 (instead of 50) and so on.
This will cause the byte counter to report numbers that are way off.
The text was updated successfully, but these errors were encountered:
85danf
pushed a commit
to 85danf/redline
that referenced
this issue
Jan 17, 2018
The logic
ReadableChannelWrapper::read
expects to have the buffer filled in its entirety in one go since it will callconsumers
with the buffer flipped (so it reports theremaining
counter as the total amount read).Consider an incoming InputStream that is not file-system based (say, nfs or incoming from socket) and may not fill the entire buffer (which has an expected size) in one read:
Suppose buffer is allocated with 100 and first read call fills it with 30.
In the case we observed consumers are now called with
buffer.duplicate().flip()
which will report 30 as as itsremaining()
.we had a 'byte counting' consumer (inited with
ReadableChannelWrapper::start
) which simply has the logiccount += buffer.remaining()
so count is now at 30.
Suppose next read gets another 20.
Now
buffer.remaining()
== 50 socount += buffer.remaining()
--> 80 (instead of 50) and so on.This will cause the byte counter to report numbers that are way off.
The text was updated successfully, but these errors were encountered: