From 127df9663518ce8c78aacab9e49325eba63c7edf Mon Sep 17 00:00:00 2001 From: Dmitry Ivanov Date: Thu, 20 Jan 2022 02:17:53 +0300 Subject: [PATCH] [proxy] Make `NUM_BYTES_PROXIED_COUNTER` more precise --- proxy/src/proxy.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/proxy/src/proxy.rs b/proxy/src/proxy.rs index 618922f7fd..5a64dc8081 100644 --- a/proxy/src/proxy.rs +++ b/proxy/src/proxy.rs @@ -360,8 +360,8 @@ fn proxy( // `std::io::copy` is guaranteed to exit if we return an error, // so we can afford to lose `res` in case `flush` fails let res = self.0.write(buf); - if res.is_ok() { - NUM_BYTES_PROXIED_COUNTER.inc_by(buf.len() as u64); + if let Ok(count) = res { + NUM_BYTES_PROXIED_COUNTER.inc_by(count as u64); self.flush()?; } res