summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2018-10-11 18:22:05 -0400
committerGitHub <noreply@github.com>2018-10-11 18:22:05 -0400
commit4f4075307d932d2be0d988f7edae6cabc38527ea (patch)
treecb91a393abb86a1ec290b97bdd6f3e8a1b388526
parentd4f72e18bedda726a74ec0960e59e304055f9039 (diff)
Fix metrics() race condition. (#965)
-rw-r--r--src/isolate.rs5
1 files changed, 1 insertions, 4 deletions
diff --git a/src/isolate.rs b/src/isolate.rs
index 408259c5f..e24471356 100644
--- a/src/isolate.rs
+++ b/src/isolate.rs
@@ -157,6 +157,7 @@ impl Isolate {
}
pub fn respond(&mut self, req_id: i32, buf: Buf) {
+ self.state.metrics_op_completed(buf.len() as u64);
// TODO(zero-copy) Use Buf::leak(buf) to leak the heap allocated buf. And
// don't do the memcpy in ImportBuf() (in libdeno/binding.cc)
unsafe {
@@ -284,8 +285,6 @@ extern "C" fn pre_dispatch(
// Set the synchronous response, the value returned from isolate.send().
isolate.respond(req_id, buf);
}
-
- isolate.state.metrics_op_completed(buf_size as u64);
} else {
// Execute op asynchronously.
let state = Arc::clone(&isolate.state);
@@ -297,9 +296,7 @@ extern "C" fn pre_dispatch(
let task = op
.and_then(move |buf| {
- let buf_size = buf.len();
state.send_to_js(req_id, buf);
- state.metrics_op_completed(buf_size as u64);
Ok(())
}).map_err(|_| ());
tokio::spawn(task);