mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 07:14:47 -05:00
fix(ext/web): fix potential leak of unread buffers (#23923)
Because the buffers are `MaybeUninit<V8Slice<u8>`, and the owner of the `BoundedBufferChannel` is not obligated to read each and every bit of data, we may find that some buffers were not automatically dropped if unread by the time the `BoundedBufferChannelInner` is dropped. Possible repro: ``` Deno.serve(() => new Response(new ReadableStream({ start(controller) { controller.enqueue(new Uint8Array(100_000_000)) } }))); ``` ```bash while true; do curl localhost:8000 | dd count=1; done ```
This commit is contained in:
parent
a5111fbc4d
commit
625d09937a
1 changed files with 7 additions and 0 deletions
|
@ -66,6 +66,13 @@ impl Default for BoundedBufferChannelInner {
|
|||
}
|
||||
}
|
||||
|
||||
impl Drop for BoundedBufferChannelInner {
|
||||
fn drop(&mut self) {
|
||||
// If any buffers remain in the ring, drop them here
|
||||
self.drain(std::mem::drop);
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for BoundedBufferChannelInner {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.write_fmt(format_args!(
|
||||
|
|
Loading…
Reference in a new issue