-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Make resource requests cancelable (issue 4974) #5826
Conversation
Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @Ms2ger (or someone else) soon. |
Critic review: https://critic.hoppipolla.co.uk/r/4786 This is an external review system which you may optionally use for the code review of your pull request. In order to help critic track your changes, please do not make in-place history rewrites (e.g. via |
Thanks for this PR @marcusklaas! There are two main issues with the code right now:
I think we can solve both of these problems together by creating an AutoResponseCleanup value that has a destructor that:
Does that make sense? |
Reviewed files:
components/net/file_loader.rs, line 39 [r1] (raw file): components/net/http_loader.rs, line 354 [r1] (raw file): components/net/resource_task.rs, line 251 [r1] (raw file): components/net/resource_task.rs, line 290 [r1] (raw file): Comments from the review on Reviewable.io |
Thank you for feedback and patience Josh! I understand the issues, but it's not exactly clear to me how this Please forgive my ignorance, but can't we just remove the relevant item from the hash map when we receive a cancel control message? This would solve the first issue, no? |
Well, we also need to remove the item when the response is complete, regardless if it was canceled or not. |
@marcusklaas With respect to where it would live, the struct definition and its methods can live in resource_task.rs. I envision it being used like so: let mut response_cleanup = AutoResponseCleanup::new(...);
...
// send request
response_cleanup.note_request_sent();
// if response_cleanup is destroyed after this point via an early return, it will avoid calling start_sending
...
// read complete response
response_cleanup.note_response_complete()
// if response_cleanup is destroyed after this point, it will not send a `Done` message, since one has already been sent The destructor would look something like: impl Drop for AutoResponseCleanup {
fn drop(&mut self) {
// if start_sending has not been called {
let tx = start_sending(...);
tx.send(Done(Err));
} else if // response incomplete {
self.stored_progress_chan.send(Done(Err));
}
self.resource_task.send(Cleanup(self.id));
}
} Is that more clear? |
Apologies for the delay in addressing these issues. I very much intend to finish this in the next couple of days. |
Not a problem! |
-S-awaiting-review +S-needs-code-changes +S-fails-tidy We still need to add the auto removal and Done message sending as described previously. Reviewed files:
components/net/file_loader.rs, line 36 [r2] (raw file): components/net/http_loader.rs, line 363 [r2] (raw file): components/net/resource_task.rs, line 251 [r2] (raw file): Comments from the review on Reviewable.io |
This has bitrotten terribly and I don't think I can bring this to a proper end any more.. Shall I close this PR? Sorry for taking up your time, @jdm! 😟 |
Not a problem! This helped expose complexities in the design, so it served a useful purpose :) |
My attempt at tackling issue #4974. Note that even though it should be possible to cancel requests now, it is not actually used anywhere yet.