-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Support calls to the SunOS Doors API #1404
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @gnzlbg (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
@bgermann could you review this? |
Might be prudent to add illumos CI (#1405) before this goes forward. I have some demo client code to prove that this works (https://github.com/robertdfrench/rusty-doors/tree/move-unsafe-to-libc/examples/narf), and can add more for the remaining door api routines, but I'm not sure how to include that in a meaningful way without CI. |
This should be okay for each supported solarish platform (10, 11, illumos) up to now. I do not see any problem with merging this. |
Sounds good to me! There are more doors api calls still to be implemented, but these three are enough to make doors usable in Rust. If this is merged as is, I could focus on the the remainder of the API after we reach a CI strategy via #1405. |
This all looks good. One thing that would probably be good to document somewhere (though I don't know where the appropriate place would be) how to safely use rust in a door server (acting as a doors client should be fine). When Unfortunately, one of the side effects of calling I'm not sure there's a way to wrap the |
@bors: r+ |
📌 Commit ba459b7 has been approved by |
Support calls to the SunOS Doors API Doors are a lightweight IPC mechanism available in libc on Solaris & illumos. They are like unix domain sockets, but faster and more pleasant to work with. * Brief introduction: ["Doors" in SolarisTM: Lightweight RPC using File Descriptors](http://www.kohala.com/start/papers.others/doors.html) * Relevant manual pages: [DOOR_CALL(3C)](https://illumos.org/man/3C/door_call), [DOOR_CREATE(3C)](https://illumos.org/man/3C/door_create) * Tutorial I wrote: ["Revolving Doors": A tutorial on the Illumos Doors API](https://github.com/robertdfrench/revolving-door) Marking this as a draft until I have included the full api.
Can you check if
This is probably only safe as long as none of the types that live in the stack frames that get deallocated by calling |
It doesn't return twice -- it's more like A long sought after feature would be to have some sort of two-phase return from a door server thread -- one which returns the values to the caller, and then another component that'd allow the server thread to cleanup after the return data has been sent to the caller, but that hasn't happened yet (and it's unclear how difficult that would be to implement). Would maybe a 'noreturn' attribute be better (though the clang/LLVM docs are a bit vague on what it actually does/expects such functions to do). |
☀️ Test successful - checks-cirrus-freebsd-11, checks-cirrus-freebsd-12, checks-travis, status-appveyor |
@jasonbking thank you for pointing this out, I had not understood that fully. I will submit a new PR to document this risk (and maybe gather feedback about where that documentation should live). As for using it safely, the work here is extracted from a crate that I am making that would (hopefully) allow users to write door server procedures in a way that smells syntactically like Rust's closures: I do this by implementing a ServerProcedure trait that exposes a doors-compatible server procedure named "C" which wraps a user-supplied rust function named "rust": My specific implementation is certainly dubious, but I think in general it sounds like this strategy would allow for drop to work as normal, because after the inner "rust" function returns, the outer "C" function only has an array of c_char and an array of door descriptors, neither of which have denstructors. Or, am I wrong in thinking that those arrays will be cleaned up by the kernel at some point? I think you told me this before and maybe it didn't sink in right -- whose responsibility is it to free the server procedure arguments? |
The parameters into the function I think should be fine (though I'd need to confirm), though if you want to return any data, that will need to survive beyond the 'rust' function to be passed to the Of course if you just pass back file descriptors, that's not a problem. It's just when returning a block of memory that things can get tricky. |
Doors are a lightweight IPC mechanism available in libc on Solaris & illumos. They are like unix domain sockets, but faster and more pleasant to work with.
Marking this as a draft until I have included the full api.