diff options
author | João Souto <joao.jpgs@hotmail.com> | 2020-03-11 22:19:24 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-11 18:19:24 -0400 |
commit | fb5c31416d4b9e526ca0fcc134dc8f366e367012 (patch) | |
tree | cffd644e8f6b99db10a75ecb6e32879d9f4c3ce0 /cli/ops/fs.rs | |
parent | 810e4a16bedbc77ef0651f4f24626d98ca566083 (diff) |
Add waker to StreamResource to fix hang on close bugs (#4293)
Diffstat (limited to 'cli/ops/fs.rs')
-rw-r--r-- | cli/ops/fs.rs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/cli/ops/fs.rs b/cli/ops/fs.rs index 4ef59e8e7..01ce548ba 100644 --- a/cli/ops/fs.rs +++ b/cli/ops/fs.rs @@ -1,7 +1,7 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. // Some deserializer fields are only used on Unix and Windows build fails without it use super::dispatch_json::{blocking_json, Deserialize, JsonOp, Value}; -use super::io::{FileMetadata, StreamResource}; +use super::io::{FileMetadata, StreamResource, StreamResourceHolder}; use crate::fs as deno_fs; use crate::op_error::OpError; use crate::ops::dispatch_json::JsonResult; @@ -153,7 +153,10 @@ fn op_open( let mut state = state_.borrow_mut(); let rid = state.resource_table.add( "fsFile", - Box::new(StreamResource::FsFile(fs_file, FileMetadata::default())), + Box::new(StreamResourceHolder::new(StreamResource::FsFile( + fs_file, + FileMetadata::default(), + ))), ); Ok(json!(rid)) }; @@ -198,12 +201,12 @@ fn op_seek( }; let state = state.borrow(); - let resource = state + let resource_holder = state .resource_table - .get::<StreamResource>(rid) + .get::<StreamResourceHolder>(rid) .ok_or_else(OpError::bad_resource_id)?; - let tokio_file = match resource { + let tokio_file = match resource_holder.resource { StreamResource::FsFile(ref file, _) => file, _ => return Err(OpError::bad_resource_id()), }; |