mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
net: Start reducing number of IPCs channels used for fetch with a FetchThread
(#33863)
Instead of creating a `ROUTER` for each fetch, create a fetch thread which handles all incoming and outcoming fetch requests. Now messages involving fetches carry a "request id" which indicates which fetch is being addressed by the message. This greatly reduces the number of file descriptors used by fetch. In addition, the interface for kicking off fetches is simplified when using the `Listener` with `Document`s and the `GlobalScope`. This does not fix all leaked file descriptors / mach ports, but greatly eliminates the number used. Now tests can be run without limiting procesess on modern macOS systems. Followup work: 1. There are more instances where fetch is done using the old method. Some of these require more changes in order to be converted to the `FetchThread` approach. 2. Eliminate usage of IPC channels when doing redirects. 3. Also eliminate the IPC channel used for cancel handling. 4. This change opens up the possiblity of controlling the priority of fetch requests. Fixes #29834. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
2115267328
commit
036e74524a
31 changed files with 761 additions and 766 deletions
|
@ -21,6 +21,7 @@ use html5ever::tree_builder::{ElementFlags, NextParserState, NodeOrText, QuirksM
|
|||
use html5ever::{local_name, namespace_url, ns, Attribute, ExpandedName, LocalName, QualName};
|
||||
use hyper_serde::Serde;
|
||||
use mime::{self, Mime};
|
||||
use net_traits::request::RequestId;
|
||||
use net_traits::{
|
||||
FetchMetadata, FetchResponseListener, Metadata, NetworkError, ResourceFetchTiming,
|
||||
ResourceTimingType,
|
||||
|
@ -759,11 +760,11 @@ impl ParserContext {
|
|||
}
|
||||
|
||||
impl FetchResponseListener for ParserContext {
|
||||
fn process_request_body(&mut self) {}
|
||||
fn process_request_body(&mut self, _: RequestId) {}
|
||||
|
||||
fn process_request_eof(&mut self) {}
|
||||
fn process_request_eof(&mut self, _: RequestId) {}
|
||||
|
||||
fn process_response(&mut self, meta_result: Result<FetchMetadata, NetworkError>) {
|
||||
fn process_response(&mut self, _: RequestId, meta_result: Result<FetchMetadata, NetworkError>) {
|
||||
let (metadata, error) = match meta_result {
|
||||
Ok(meta) => (
|
||||
Some(match meta {
|
||||
|
@ -914,7 +915,7 @@ impl FetchResponseListener for ParserContext {
|
|||
}
|
||||
}
|
||||
|
||||
fn process_response_chunk(&mut self, payload: Vec<u8>) {
|
||||
fn process_response_chunk(&mut self, _: RequestId, payload: Vec<u8>) {
|
||||
if self.is_synthesized_document {
|
||||
return;
|
||||
}
|
||||
|
@ -932,7 +933,11 @@ impl FetchResponseListener for ParserContext {
|
|||
// This method is called via script_thread::handle_fetch_eof, so we must call
|
||||
// submit_resource_timing in this function
|
||||
// Resource listeners are called via net_traits::Action::process, which handles submission for them
|
||||
fn process_response_eof(&mut self, status: Result<ResourceFetchTiming, NetworkError>) {
|
||||
fn process_response_eof(
|
||||
&mut self,
|
||||
_: RequestId,
|
||||
status: Result<ResourceFetchTiming, NetworkError>,
|
||||
) {
|
||||
let parser = match self.parser.as_ref() {
|
||||
Some(parser) => parser.root(),
|
||||
None => return,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue