summaryrefslogtreecommitdiff
path: root/cli/ops/mod.rs
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2019-08-16 11:05:24 -0400
committerRyan Dahl <ry@tinyclouds.org>2019-08-16 14:41:08 -0400
commit81f809f2a675ff4ff7f93231ca87a18cb5b4628e (patch)
tree09a8bd8eedc5b03a4399cdfac896b2d445ed8037 /cli/ops/mod.rs
parent52a66c2796f97f5a08d679389172c39c0652cb16 (diff)
Revert "Remove dead code: legacy read/write ops"
This is causing a segfault for unknown reasons - see #2787. This reverts commit 498f6ad431478f655b136782093e19e29248b24d.
Diffstat (limited to 'cli/ops/mod.rs')
-rw-r--r--cli/ops/mod.rs28
1 files changed, 10 insertions, 18 deletions
diff --git a/cli/ops/mod.rs b/cli/ops/mod.rs
index bf621e0e1..021c0fa47 100644
--- a/cli/ops/mod.rs
+++ b/cli/ops/mod.rs
@@ -1,5 +1,7 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
use crate::deno_error::GetErrorKind;
+use crate::dispatch_minimal::dispatch_minimal;
+use crate::dispatch_minimal::parse_min_record;
use crate::msg;
use crate::state::ThreadSafeState;
use crate::tokio_util;
@@ -11,15 +13,12 @@ use hyper;
use hyper::rt::Future;
use tokio_threadpool;
-mod dispatch_minimal;
-mod io;
-
mod compiler;
use compiler::{op_cache, op_fetch_source_file};
mod errors;
use errors::{op_apply_source_map, op_format_error};
mod files;
-use files::{op_close, op_open, op_seek};
+use files::{op_close, op_open, op_read, op_seek, op_write};
mod fetch;
use fetch::op_fetch;
mod fs;
@@ -72,8 +71,6 @@ fn empty_buf() -> Buf {
}
const FLATBUFFER_OP_ID: OpId = 44;
-const OP_READ: OpId = 1;
-const OP_WRITE: OpId = 2;
pub fn dispatch_all(
state: &ThreadSafeState,
@@ -84,18 +81,11 @@ pub fn dispatch_all(
) -> CoreOp {
let bytes_sent_control = control.len();
let bytes_sent_zero_copy = zero_copy.as_ref().map(|b| b.len()).unwrap_or(0);
-
- let op = match op_id {
- OP_READ => {
- dispatch_minimal::dispatch(io::op_read, state, control, zero_copy)
- }
- OP_WRITE => {
- dispatch_minimal::dispatch(io::op_write, state, control, zero_copy)
- }
- FLATBUFFER_OP_ID => {
- dispatch_all_legacy(state, control, zero_copy, op_selector)
- }
- _ => panic!("bad op_id"),
+ let op = if op_id != FLATBUFFER_OP_ID {
+ let min_record = parse_min_record(control).unwrap();
+ dispatch_minimal(state, op_id, min_record, zero_copy)
+ } else {
+ dispatch_all_legacy(state, control, zero_copy, op_selector)
};
state.metrics_op_dispatched(bytes_sent_control, bytes_sent_zero_copy);
op
@@ -236,6 +226,7 @@ pub fn op_selector_std(inner_type: msg::Any) -> Option<CliDispatchFn> {
msg::Any::Open => Some(op_open),
msg::Any::PermissionRevoke => Some(op_revoke_permission),
msg::Any::Permissions => Some(op_permissions),
+ msg::Any::Read => Some(op_read),
msg::Any::ReadDir => Some(op_read_dir),
msg::Any::Readlink => Some(op_read_link),
msg::Any::Remove => Some(op_remove),
@@ -254,6 +245,7 @@ pub fn op_selector_std(inner_type: msg::Any) -> Option<CliDispatchFn> {
msg::Any::Truncate => Some(op_truncate),
msg::Any::HomeDir => Some(op_home_dir),
msg::Any::Utime => Some(op_utime),
+ msg::Any::Write => Some(op_write),
// TODO(ry) split these out so that only the appropriate Workers can access
// them.