Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unix: copy buffer before passing off to client #502

Merged
merged 2 commits into from Feb 20, 2023

Conversation

reynir
Copy link
Member

@reynir reynir commented Feb 9, 2023

Originally reported by @rand00.

let b = Cstruct.create_unsafe len in
Cstruct.blit buf 0 b 0 len;
b
in
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe use Cstruct.copy?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cstruct.copy is Cstruct.t -> int -> int -> string, that is, Cstruct.copy t off len is the same as Cstruct.to_string t ~off ~len :/ I didn't see a function to copy a cstruct (even though Cstruct.copy would be an obvious name for such a function)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name is Cstruct.sub_copy ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @palainp, indeed, Cstruct.sub_copy does what I want, but it only exists in unreleased cstruct. I can put a comment in the code to use Cstruct.sub_copy in the future.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh sorry, didn't checked the last release date :(

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will cut a release of cstruct as soon as I can but some improvements are not merged yet.

@reynir reynir merged commit 665d9b0 into mirage:main Feb 20, 2023
@reynir reynir deleted the stack-unix-buffer-ownership branch February 20, 2023 10:29
hannesm added a commit to hannesm/opam-repository that referenced this pull request Mar 17, 2023
CHANGES:

* TCP: add ID for PCB for connection tracking (mirage/mirage-tcpip#495 @TheLortex)
* Unix stack, UDP: copy buffer before passing it to client (mirage/mirage-tcpip#502 @reynir)

* API renamings (due to ppx_cstruct removal): accessors such as
  Icmpv4_wire.get_icmpv4_ty are now Icmpv4_wire.get_ty ("_icmpv4" is removed)
  (mirage/mirage-tcpip#505)

* Use Cstruct.to_string instead of deprecated Cstruct.copy (mirage/mirage-tcpip#506 @hannesm)
* Remove ppx_cstruct dependency (mirage/mirage-tcpip#505 @hannesm)
* Remove mirage-profile dependency (mirage/mirage-tcpip#504 @hannesm)
* Remove Mirage3 cross-compilation runes (mirage/mirage-tcpip#507 @hannesm)
* opam: add lower bounds for cmdliner and alcotest (mirage/mirage-tcpip#506 @hannesm)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants