mirror of
https://github.com/servo/servo.git
synced 2025-08-11 08:25:32 +01:00
net: clean shutdown of fetch thread (#38421)
The fetch thread is currently not shut down, meaning it is one of the threads counted in the "threads are still running after shutdown (bad)" counter shown when Servo has shut-down. This PR introduces a mechanism to start, and shut-down, one fetch thread per process that requires one. Testing: WPT tests and unit tests(for font context). Also manually tested loading and closing "about:blank": this change indeed brings down the count of threads still running after shutdown by one. Fixes: https://github.com/servo/servo/issues/34887 --------- Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
This commit is contained in:
parent
ad805e3110
commit
b23cf9c6cd
5 changed files with 71 additions and 11 deletions
|
@ -9,8 +9,8 @@ mod font_context {
|
|||
use std::collections::HashMap;
|
||||
use std::ffi::OsStr;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicI32, Ordering};
|
||||
use std::sync::{Arc, Once};
|
||||
use std::thread;
|
||||
|
||||
use app_units::Au;
|
||||
|
@ -23,7 +23,7 @@ mod font_context {
|
|||
SystemFontServiceProxySender, fallback_font_families,
|
||||
};
|
||||
use ipc_channel::ipc::{self, IpcReceiver};
|
||||
use net_traits::ResourceThreads;
|
||||
use net_traits::{ResourceThreads, exit_fetch_thread, start_fetch_thread};
|
||||
use parking_lot::Mutex;
|
||||
use servo_arc::Arc as ServoArc;
|
||||
use style::ArcSlice;
|
||||
|
@ -36,6 +36,8 @@ mod font_context {
|
|||
use stylo_atoms::Atom;
|
||||
use webrender_api::{FontInstanceKey, FontKey, IdNamespace};
|
||||
|
||||
static INIT: Once = Once::new();
|
||||
|
||||
struct TestContext {
|
||||
context: FontContext,
|
||||
system_font_service: Arc<MockSystemFontService>,
|
||||
|
@ -53,6 +55,9 @@ mod font_context {
|
|||
let mock_compositor_api = CrossProcessCompositorApi::dummy();
|
||||
|
||||
let proxy_clone = Arc::new(system_font_service_proxy.to_sender().to_proxy());
|
||||
INIT.call_once(|| {
|
||||
start_fetch_thread(&mock_resource_threads.core_thread);
|
||||
});
|
||||
Self {
|
||||
context: FontContext::new(proxy_clone, mock_compositor_api, mock_resource_threads),
|
||||
system_font_service,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue