Fix GC borrow hazards triggered by LoadBlocker::terminate (#34122)

* Fix GC borrow hazards triggered by LoadBlocker::terminate

Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>

* Fix clippy warnings

Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>

* Use borrow_mut()

Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>

* Revert to previous code due to crown unrooted error

Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>

* Update test expectations

Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>

---------

Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>
This commit is contained in:
tanishka 2024-11-05 03:57:41 +05:30 committed by GitHub
parent 072ff302d2
commit cc6163dcdd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 34 additions and 40 deletions

View file

@ -11,6 +11,7 @@ use net_traits::request::RequestBuilder;
use net_traits::{fetch_async, BoxedFetchCallback, ResourceThreads};
use servo_url::ServoUrl;
use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::root::Dom;
use crate::dom::document::Document;
use crate::fetch::FetchCanceller;
@ -49,11 +50,12 @@ impl LoadBlocker {
}
/// Remove this load from the associated document's list of blocking loads.
pub fn terminate(blocker: &mut Option<LoadBlocker>, can_gc: CanGc) {
if let Some(this) = blocker.as_mut() {
this.doc.finish_load(this.load.take().unwrap(), can_gc);
pub fn terminate(blocker: &DomRefCell<Option<LoadBlocker>>, can_gc: CanGc) {
if let Some(this) = blocker.borrow().as_ref() {
let load_data = this.load.clone().unwrap();
this.doc.finish_load(load_data, can_gc);
}
*blocker = None;
*blocker.borrow_mut() = None;
}
}