net: clean shutdown of the async runtime (#38425)

The previous use of a static variable for the runtime prevented it from
shutting down cleanly, because shutdown requires dropping or taking
ownership of it. This PR switches the static variable to a handle only,
and introduces a new trait to pass a handle to the async runtime to the
constellation, where it can be shut-down along with other components and
help reduce our count of still running threads after shutdown.

Testing: manual testing, and covered by unit-test in net, and wpt tests.
Fixes: part of - https://github.com/servo/servo/issues/30849

---------

Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
This commit is contained in:
Gregory Terzian 2025-08-05 05:42:47 +08:00 committed by GitHub
parent 7ad32f944f
commit 77ff351cde
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 132 additions and 49 deletions

View file

@ -49,7 +49,7 @@ use url::Url;
use crate::{
create_embedder_proxy_and_receiver, fetch, fetch_with_context, make_body, make_server,
new_fetch_context, receive_credential_prompt_msgs,
new_fetch_context, receive_credential_prompt_msgs, spawn_blocking_task,
};
fn mock_origin() -> ImmutableOrigin {
@ -1611,7 +1611,7 @@ fn test_fetch_compressed_response_update_count() {
sender: Some(sender),
update_count: 0,
};
let response_update_count = crate::HANDLE.block_on(async move {
let response_update_count = spawn_blocking_task::<_, Response>(async move {
methods::fetch(
request,
&mut target,