Closed ansiwen closed 2 years ago
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.
Ok, so ownership is transferred. Thanks. So I will close this.
The
write
function inUser_buffer
possibly copiesCstruct
values into a list and returns:https://github.com/mirage/mirage-tcpip/blob/a7b799cb36435ecb810a92df05ff49fbd264bfbb/src/tcp/user_buffer.ml#L256-L277
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: https://github.com/anmonteiro/gluten/issues/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?