-
Notifications
You must be signed in to change notification settings - Fork 226
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
TrapCaps for async host, synchronous guest relationships #3171
Conversation
b596232
to
61f6a30
Compare
61f6a30
to
3989998
Compare
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 left some comments. I definitely need to read what’s already in CapTP top-to-bottom to have the knowledge necessary to give this a hearty stamp. What I see looks fine, except a strong feeling handler behaviors shouldn’t be conflated into a single utility function.
I would like to see a code sample of how this would interact with SharedBuffer and Atomics, if not a working example.
I may supply such an example, but it will be only a part of a PR stacked on top of this PR. The simplest correct implementation of Worker/postMessage/SharedArrayBuffer/Atomics is at least 100 lines of code, even when given the foundation in this PR. |
41a8128
to
6a340c9
Compare
@erights please hold off on this review until I provide an example as requested by @kriskowal. The factoring of such an example will inform what API captp should provide. |
edea844
to
4f60874
Compare
@erights and @kriskowal, this is now fully-baked and ready for a review. Notably, the |
4f60874
to
b1816d1
Compare
da49aef
to
1fdb173
Compare
525fef3
to
0f5a1e6
Compare
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.
Just some review comments so far.
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.
If I remain tardy in reviewing this PR (sorry), would it be useful to extract the #2846 fix as a distinct PR so it can go in asap?
17b0b1d
to
c0c8e95
Compare
44ba004
to
a350b9d
Compare
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.
Comments so far.
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.
The loopback case doesn't make any use of iteration, because of course not. This has me wondering whether the generic types should hide rather that expose the iterators on both side, so that it is only the business of an individual makeGuest/makeHost pair (like atomics) whether it needs iterators or not.
#3171 (comment) is my only comment that is likely a bug. The others are questions, suggestions, or things to discuss. |
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.
LGTM!
But please don't merge until we talk
Fixes #2846 while we're in the neighbourhood.
As discussed with @erights and @kriskowal, this implements the possibility for a Host captp endpoint to serve synchronous Trap requests made by a trusting Guest captp endpoint. See
test-trap.js
for how it works.Essentially, Alice's can set
opts.giveTrapReply
and serve amakeTrapHandler(name, object)
, which when given the rightopts.takeTrapReply
on Bob's side, permits Bob to callTrap(remotable)[prop](...args)
(orTrap.get(remotable)[prop]
orTrap(remotable)(...args)
), blocking and waiting for Alice to asynchronously resolve the answer normally, but Bob sees the result as if it were synchronous.This must only be used when Bob can and must depend on Alice's correct functioning, such as when Alice is a device-driver-like service. Using it in other ways leads to madness.