-
Notifications
You must be signed in to change notification settings - Fork 10
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
Add Async support #18
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this, thank you :)
I'm not keen on maintaining async stuff myself, so if you're ok with maintaining this async bits in the future I'd appreciate, otherwise it will end up rotting.
let send_packet t buf = | ||
let len = Cstruct.length buf in | ||
let writer = Writer.create t.fd in | ||
Writer.write_bytes ~pos:0 ~len writer (Cstruct.to_bytes ~len buf); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know async at all, but is this the only way to do a write ? does it guarantee this is one system call ? These are all datagram-like file descriptors, meaning one write = one packet
.
I guess this is ok but maybe there is a single_write
and whatnot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've looked it over and it does look like I need to use Writer.write_gen_whole to ensure we don't break up the write. Unfortunately that interface seems needlessly obtuse. I'll switch it to that function shortly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
schedule_write does the correct thing, and now much more closely matches what lwt and eio are doing.
0e54b9c
to
230ee73
Compare
That's great, I'll have a proper review in this and all the other PRs tomorrow, I'll test this during the weekend in my network home to see if nothing breaks thanks again for your work |
This adds Async support, it has been tested by using these modules in the Churrua DHCP server, and works well.
Since Async depends on
Core
andppx_jane
already, I used that in the rawcap_async test binary. It could just as easily useAsync.Deferred.run_in_async_wait
instead of the Command module to start the process. If there is desire to keeprawcap_async
as minimal as possible.