-
Notifications
You must be signed in to change notification settings - Fork 107
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
Implement Drop
for handles / channels in Rust SDK
#1686
Comments
I guess the complication is that |
Manually for now, likely to be superceded by project-oak#1686
In a java project the answer would have been dependency injection (something like adding an For #1676 the issue can be addressed by updating the generated client code to to close the invocation sender in I am not sure how to address the more general issue when sending protos that contain handles. In principle we could always close the handles that are being extracted by HandleVisit, but this might be unexpected behaviour for an implementer. |
I am slightly reluctant to add special handling for closing channels here and there as a best effort. Especially for gRPC clients, which I think are not really expected to be dropped throughout the execution of an application. Also the channel is already there (e.g. as returned from the node creation call), so it feels odd that it will only be correctly closed if it is actually used as part of a gRPC client, but if not it will be left to leak. |
Manually for now, likely to be superceded by project-oak#1686
Manually for now, likely to be superceded by project-oak#1686
Manually for now, likely to be superceded by #1686
Looking some more into it, I think it may not be possible to |
@wildarch do you have any suggestions? |
I'm trying to understand the blocker here for a direct |
Yes, |
My first instinct was to Since we need to run a different destructor depending on the environment we use |
The reason for having Sender and Receiver in oak_io was that the same generated code may be used in both the runtime and in the SDK, and then each of them uses extension traits to define operations on the same underlying types. I think what you are suggesting would require generating different code for runtime and SDK, right? (which is not necessarily a bad thing, maybe it would be simpler overall) WDYT? |
Correct, yes. The logic that can be shared would live in the The logic that is currently in the extension methods would live in the |
I've been experimenting with a few ideas here:
Now I have noticed that Do we want to consider doing more bookkeeping to keep track of individual copies of handles? We could add ABI calls like |
Yes I would expect these types should stop being Copy, and we may provide a manual impl of Clone that actually dups the handle via a new ABI call (though for the time being we will just disallow cloning, I guess). |
|
Aah yes, good point, we can just reuse |
Here is my game plan for making handles linear types:
Of course we could also do all of this at once (e.g. https://github.com/wildarch/oak/tree/handle_clone_drop_impls), but I suspect that would be a very tough PR to land, because it touches so much of the codebase. |
It would be useful to fix it at the
Sender
andReceiver
level (or even better at theReadHandle
andWriteHandle
level) if it is feasible. That will also solve a related issue with the router pattern. When the router receives a gRPC invocation, it must remember to close its handles to the request and response channels in the invocation after sending it to the target node to avoid potential channel leaks. In general, any node that receives a proto containing handles must remember to close all of the handles even if it does not do anything with the proto apart from sending it to another node.Originally posted by @conradgrobler in #1676 (comment)
The text was updated successfully, but these errors were encountered: