-
Notifications
You must be signed in to change notification settings - Fork 48
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 more graceful tokio limbo send_off #72
base: main
Are you sure you want to change the base?
Conversation
Issue: #71 |
This fix isn't quite right, since The more correct solution here would be to send the handle to the sync limbo instead, which avoids blocking the runtime during the shutdown process.
Yea, that bit is a little silly. My original intent there was to piggyback off of Tokio's thread pool and thus dead-code-eliminate the one sync named pipes roll in crates that only use the Tokio side of things.
Close errors can be explicitly requested via |
The send_off method now properly falls back to a static tokio runtime if required.
Oh right, I did not think about untrusted clients and potential lockups. Thanks for pointing out After giving it some more thoughts, I think starting a static tokio runtime maybe isn't so fancy, but it is indeed one of the better solutions here. Sending the corpses off to the sync limbo requires some refactoring. Currently they are not compatible with each other. I updated the PR with a I have two open thoughts though:
|
This is a matter of turning the Tokio stream into an owned handle.
To the best of my knowledge, there is nothing to reuse – Tokio doesn't flush in named pipes (as in, there isn't a single Using Tokio's |
Alright. It was just a thought. I did not go all the way down the
I did not plan implementing changes or do refactoring outside of the tokio limbo here. This is not something I would be comfortable doing. I am so far fine with the current PR then. |
Hi!
First of all, thank you for your work! Interprocess has been very beneficial in my projects so far.
This PR addresses a potential panic in the SendHalf drop implementation and the send_off method
The new implementation takes a more graceful approach when attempting to send off the corpse.
It falls back to a synchronous bury if there is no active limbo channel and there is no tokio runtime is available.
I also removed the static runtime because I think starting a new runtime in a drop implementation is a bit much hidden cost.
The static runtime would also not help in this case because tokio disallows starting a runtime inside a runtime. (even when one is shutting down)
I noticed that most drop implementations in this crate do not bury the corpse directly but send it off either to another thread or here to a tokio runtime. I would not expect much performance (latency) regression with this synchronous bury because this is more a edge-case. But I'm not completly in the picture, do you see it the same way?
Off-topic from this PR:
I feel that having that much logic in the drop implemenations is rather bad because there is no way to propagate results back to the crate user. Maybe consider in the future to refactor the bury logic into seperate .shutdown() or .disconnect() methods without implict thread or task spawning. But that looks like no easy task though, so thats another story.
Also note:
I left quite a few comments with more details in the repro and in the PR.
Thanks for looking into it! 😊