Closed struktured closed 9 years ago
You're right, I forgot that the initial index may change when filling the buffer. I will recheck the code.
According to the documentation of fill_in_buf_or_Eof
, in0 = in1 = 0
can only occur on non-blocking channels. It is not propagated upward though. (If you really need non-blocking channels, the whole library needs to be revisited — one may try to factor it so functions can be used both on blocking channels but also with Lwt or Async).
May you please test again?
Tested using your own version of the fix and seems to work fine. Thanks.
It amounts to the same as your fix but I wanted to code to insist on the fact that ic.in0
is the important variable to consider — instead of "hiding" it behind i
! ;-)
This took a while to find because
Bytes.unsafe_get
silently returned garbage whenever the buffer got refilled and the index was out of bounds.Also, I'm not sure what happens if
ic.in0 = ic.in1 = 0
. If this would ever happen in that code path it might lead to undefined behavior.