mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
fix: ReadableStream::get_in_memory_bytes
too large (#36914)
Fix a IPC hang due to `ReadableStream::get_in_memory_bytes` could return really huge chunk. Testing: WPT on ReadableStream should pass Fixes: IPC hang when transferring huge chunk bytes from `ReadableStream` cc @gterzian @Taym95 since this is also related to ReadableStream. --------- Signed-off-by: Yu Wei Wu <yuweiwu@YunoMacBook-Air.local> Co-authored-by: Yu Wei Wu <yuweiwu@YunoMacBook-Air.local>
This commit is contained in:
parent
c37d5572fd
commit
aa4ad0f2be
5 changed files with 29 additions and 20 deletions
|
@ -7,7 +7,7 @@ use std::{ptr, slice, str};
|
|||
|
||||
use constellation_traits::BlobImpl;
|
||||
use encoding_rs::{Encoding, UTF_8};
|
||||
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
|
||||
use ipc_channel::ipc::{self, IpcReceiver, IpcSender, IpcSharedMemory};
|
||||
use ipc_channel::router::ROUTER;
|
||||
use js::jsapi::{Heap, JS_ClearPendingException, JSObject, Value as JSValue};
|
||||
use js::jsval::{JSVal, UndefinedValue};
|
||||
|
@ -73,7 +73,7 @@ struct TransmitBodyConnectHandler {
|
|||
task_source: SendableTaskSource,
|
||||
bytes_sender: Option<IpcSender<BodyChunkResponse>>,
|
||||
control_sender: IpcSender<BodyChunkRequest>,
|
||||
in_memory: Option<Vec<u8>>,
|
||||
in_memory: Option<IpcSharedMemory>,
|
||||
in_memory_done: bool,
|
||||
source: BodySource,
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ impl TransmitBodyConnectHandler {
|
|||
stream: Trusted<ReadableStream>,
|
||||
task_source: SendableTaskSource,
|
||||
control_sender: IpcSender<BodyChunkRequest>,
|
||||
in_memory: Option<Vec<u8>>,
|
||||
in_memory: Option<IpcSharedMemory>,
|
||||
source: BodySource,
|
||||
) -> TransmitBodyConnectHandler {
|
||||
TransmitBodyConnectHandler {
|
||||
|
@ -160,7 +160,7 @@ impl TransmitBodyConnectHandler {
|
|||
.bytes_sender
|
||||
.as_ref()
|
||||
.expect("No bytes sender to transmit source.")
|
||||
.send(BodyChunkResponse::Chunk(bytes.clone()));
|
||||
.send(BodyChunkResponse::Chunk(bytes));
|
||||
return;
|
||||
}
|
||||
warn!("Re-directs for file-based Blobs not supported yet.");
|
||||
|
@ -310,7 +310,11 @@ impl Callback for TransmitBodyPromiseHandler {
|
|||
// Step 5.1 and 5.2, transmit chunk.
|
||||
// Send the chunk to the body transmitter in net::http_loader::obtain_response.
|
||||
// TODO: queue a fetch task on request to process request body for request.
|
||||
let _ = self.bytes_sender.send(BodyChunkResponse::Chunk(chunk));
|
||||
let _ = self
|
||||
.bytes_sender
|
||||
.send(BodyChunkResponse::Chunk(IpcSharedMemory::from_bytes(
|
||||
&chunk,
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue