mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
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:
parent
7ad32f944f
commit
77ff351cde
11 changed files with 132 additions and 49 deletions
|
@ -66,7 +66,7 @@ use tokio::sync::mpsc::{
|
|||
};
|
||||
use tokio_stream::wrappers::ReceiverStream;
|
||||
|
||||
use crate::async_runtime::HANDLE;
|
||||
use crate::async_runtime::spawn_task;
|
||||
use crate::connector::{CertificateErrorOverrideManager, Connector};
|
||||
use crate::cookie::ServoCookie;
|
||||
use crate::cookie_storage::CookieStorage;
|
||||
|
@ -574,7 +574,7 @@ impl BodySink {
|
|||
match self {
|
||||
BodySink::Chunked(sender) => {
|
||||
let sender = sender.clone();
|
||||
HANDLE.spawn(async move {
|
||||
spawn_task(async move {
|
||||
let _ = sender
|
||||
.send(Ok(Frame::data(Bytes::copy_from_slice(&bytes))))
|
||||
.await;
|
||||
|
@ -2090,7 +2090,7 @@ async fn http_network_fetch(
|
|||
let headers = response.headers.clone();
|
||||
let devtools_chan = context.devtools_chan.clone();
|
||||
|
||||
HANDLE.spawn(
|
||||
spawn_task(
|
||||
res.into_body()
|
||||
.map_err(|e| {
|
||||
warn!("Error streaming response body: {:?}", e);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue