From e853fa94a125976711f32e9651355e2a2534ceaf Mon Sep 17 00:00:00 2001 From: Patrick Auernig Date: Fri, 23 Mar 2018 22:53:40 +0100 Subject: [PATCH] Set fixed read buffer size --- src/connection/unix.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/connection/unix.rs b/src/connection/unix.rs index 1213317..f25d5a3 100644 --- a/src/connection/unix.rs +++ b/src/connection/unix.rs @@ -57,9 +57,10 @@ impl Connection for UnixConnection { } fn recv(&mut self) -> Result> { - let mut buf: Vec = Vec::with_capacity(1024); - self.socket.read(buf.as_mut_slice())?; - debug!("{:?}", buf); + let mut buf: Vec = vec![0; 1024]; + let n = self.socket.read(buf.as_mut_slice())?; + buf.resize(n, 0); + debug!("{:?}", Message::decode(buf.as_ref())); Ok(buf) } }