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
List.iter (fundata -> ignore(Lwt_dllist.add_r data t.buffer)) datav;
if t.bufbytes < mss then
Lwt.return_unit
else
clear_buffer t
|true ->
let avail_len = available_cwnd t in
match avail_len < l with
|true ->
t.bufbytes <-Int32.add t.bufbytes l;
List.iter (fundata -> ignore(Lwt_dllist.add_r data t.buffer)) datav;
Lwt.return_unit
|false ->
let max_size =Window.tx_mss t.wnd in
transmit_segments ~mss:max_size ~txq:t.txq datav
which basically means it takes ownership, because copies of Cstruct share the data and it's not transparent when they will be flushed. This leads to problems, when code assumes otherwise and reuses the buffers after write returns, like the Faraday library. This leads to issues like this: anmonteiro/gluten#29
I open this issue to clarify the contract conventions (if there are any) for the write function. Is the buffer ownership transferred, or only "borrowed" until write returns?
The text was updated successfully, but these errors were encountered:
I'm not sure the authors considered this much, but as you can see only the very last case (transmit_segments) is not a clear offender. We should at least document it.
The
write
function inUser_buffer
possibly copiesCstruct
values into a list and returns:mirage-tcpip/src/tcp/user_buffer.ml
Lines 256 to 277 in a7b799c
which basically means it takes ownership, because copies of Cstruct share the data and it's not transparent when they will be flushed. This leads to problems, when code assumes otherwise and reuses the buffers after
write
returns, like theFaraday
library. This leads to issues like this: anmonteiro/gluten#29I open this issue to clarify the contract conventions (if there are any) for the
write
function. Is the buffer ownership transferred, or only "borrowed" untilwrite
returns?The text was updated successfully, but these errors were encountered: