summaryrefslogtreecommitdiff
path: root/ext/flash/lib.rs
diff options
context:
space:
mode:
authorLuca Casonato <hello@lcas.dev>2022-09-30 07:54:12 +0200
committerGitHub <noreply@github.com>2022-09-30 07:54:12 +0200
commit20c7300412bdb487fc758577d6256bbcf96efd12 (patch)
tree2dcd218a6095a2ad143fb27e304391b5fe64cf27 /ext/flash/lib.rs
parent38f544538b337074cbce317e67859a69bb23684c (diff)
refactor(ext/http): remove op_http_read (#16096)
We can use Resource::read_return & op_read instead. This allows HTTP request bodies to participate in FastStream. To make this work, `readableStreamForRid` required a change to allow non auto-closing resources to be handled. This required some minor changes in our FastStream paths in ext/http and ext/flash.
Diffstat (limited to 'ext/flash/lib.rs')
-rw-r--r--ext/flash/lib.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/ext/flash/lib.rs b/ext/flash/lib.rs
index 0714e379d..a7bd8b439 100644
--- a/ext/flash/lib.rs
+++ b/ext/flash/lib.rs
@@ -205,16 +205,20 @@ async fn op_flash_write_resource(
server_id: u32,
token: u32,
resource_id: deno_core::ResourceId,
+ auto_close: bool,
) -> Result<(), AnyError> {
- let resource = op_state.borrow_mut().resource_table.take_any(resource_id)?;
- let sock = {
+ let (resource, sock) = {
let op_state = &mut op_state.borrow_mut();
+ let resource = if auto_close {
+ op_state.resource_table.take_any(resource_id)?
+ } else {
+ op_state.resource_table.get_any(resource_id)?
+ };
let flash_ctx = op_state.borrow_mut::<FlashContext>();
let ctx = flash_ctx.servers.get_mut(&server_id).unwrap();
- ctx.requests.remove(&token).unwrap().socket()
+ (resource, ctx.requests.remove(&token).unwrap().socket())
};
- drop(op_state);
let _ = sock.write(&response);
#[cfg(unix)]