Set fixed read buffer size

This commit is contained in:
Patrick Auernig 2018-03-23 22:53:40 +01:00
parent 00c61cfa72
commit e853fa94a1
1 changed files with 4 additions and 3 deletions

View File

@ -57,9 +57,10 @@ impl Connection for UnixConnection {
}
fn recv(&mut self) -> Result<Vec<u8>> {
let mut buf: Vec<u8> = Vec::with_capacity(1024);
self.socket.read(buf.as_mut_slice())?;
debug!("{:?}", buf);
let mut buf: Vec<u8> = vec![0; 1024];
let n = self.socket.read(buf.as_mut_slice())?;
buf.resize(n, 0);
debug!("{:?}", Message::decode(buf.as_ref()));
Ok(buf)
}
}