mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
net: shutdown async runtime on exit
This commit is contained in:
parent
34a41f57c6
commit
fa765168b9
2 changed files with 11 additions and 5 deletions
|
@ -59,7 +59,7 @@ use tokio::prelude::{future, Future, Stream};
|
||||||
use tokio::runtime::Runtime;
|
use tokio::runtime::Runtime;
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
pub static ref HANDLE: Mutex<Runtime> = Mutex::new(Runtime::new().unwrap());
|
pub static ref HANDLE: Mutex<Option<Runtime>> = Mutex::new(Some(Runtime::new().unwrap()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The various states an entry of the HttpCache can be in.
|
/// The various states an entry of the HttpCache can be in.
|
||||||
|
@ -95,7 +95,10 @@ impl HttpState {
|
||||||
history_states: RwLock::new(HashMap::new()),
|
history_states: RwLock::new(HashMap::new()),
|
||||||
http_cache: RwLock::new(HttpCache::new()),
|
http_cache: RwLock::new(HttpCache::new()),
|
||||||
http_cache_state: Mutex::new(HashMap::new()),
|
http_cache_state: Mutex::new(HashMap::new()),
|
||||||
client: create_http_client(tls_config, HANDLE.lock().unwrap().executor()),
|
client: create_http_client(
|
||||||
|
tls_config,
|
||||||
|
HANDLE.lock().unwrap().as_ref().unwrap().executor(),
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1613,7 +1616,7 @@ fn http_network_fetch(
|
||||||
let timing_ptr3 = context.timing.clone();
|
let timing_ptr3 = context.timing.clone();
|
||||||
let url1 = request.url();
|
let url1 = request.url();
|
||||||
let url2 = url1.clone();
|
let url2 = url1.clone();
|
||||||
HANDLE.lock().unwrap().spawn(
|
HANDLE.lock().unwrap().as_mut().unwrap().spawn(
|
||||||
res.into_body()
|
res.into_body()
|
||||||
.map_err(|_| ())
|
.map_err(|_| ())
|
||||||
.fold(res_body, move |res_body, chunk| {
|
.fold(res_body, move |res_body, chunk| {
|
||||||
|
|
|
@ -152,7 +152,7 @@ fn create_http_states(
|
||||||
http_cache_state: Mutex::new(HashMap::new()),
|
http_cache_state: Mutex::new(HashMap::new()),
|
||||||
client: create_http_client(
|
client: create_http_client(
|
||||||
create_tls_config(&certs, ALPN_H2_H1),
|
create_tls_config(&certs, ALPN_H2_H1),
|
||||||
HANDLE.lock().unwrap().executor(),
|
HANDLE.lock().unwrap().as_ref().unwrap().executor(),
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ fn create_http_states(
|
||||||
http_cache_state: Mutex::new(HashMap::new()),
|
http_cache_state: Mutex::new(HashMap::new()),
|
||||||
client: create_http_client(
|
client: create_http_client(
|
||||||
create_tls_config(&certs, ALPN_H2_H1),
|
create_tls_config(&certs, ALPN_H2_H1),
|
||||||
HANDLE.lock().unwrap().executor(),
|
HANDLE.lock().unwrap().as_ref().unwrap().executor(),
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -591,6 +591,9 @@ impl CoreResourceManager {
|
||||||
// or a short timeout has been reached.
|
// or a short timeout has been reached.
|
||||||
self.thread_pool.exit();
|
self.thread_pool.exit();
|
||||||
|
|
||||||
|
// Shut-down the async runtime used by fetch workers.
|
||||||
|
drop(HANDLE.lock().unwrap().take());
|
||||||
|
|
||||||
debug!("Exited CoreResourceManager");
|
debug!("Exited CoreResourceManager");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue