0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-10-30 09:08:00 -04:00

fix metrics logic

This commit is contained in:
Bartek Iwańczuk 2018-10-13 11:09:33 +02:00 committed by Ryan Dahl
parent 213885a9d0
commit fd2bb015c7

View file

@ -171,7 +171,6 @@ impl Isolate {
} }
pub fn respond(&mut self, req_id: i32, buf: Buf) { 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 // 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) // don't do the memcpy in ImportBuf() (in libdeno/binding.cc)
unsafe { unsafe {
@ -189,7 +188,9 @@ impl Isolate {
// completing. // completing.
self.ntasks_decrement(); self.ntasks_decrement();
// Call into JS with the buf. // Call into JS with the buf.
let buf_size = buf.len() as u64;
self.respond(req_id, buf); self.respond(req_id, buf);
self.state.metrics_op_completed(buf_size)
} }
fn timeout(&mut self) { fn timeout(&mut self) {
@ -307,6 +308,7 @@ extern "C" fn pre_dispatch(
if buf_size != 0 { if buf_size != 0 {
// Set the synchronous response, the value returned from isolate.send(). // Set the synchronous response, the value returned from isolate.send().
isolate.respond(req_id, buf); isolate.respond(req_id, buf);
isolate.state.metrics_op_completed(buf_size as u64);
} }
} else { } else {
// Execute op asynchronously. // Execute op asynchronously.