From: Wolfgang Bumiller Date: Thu, 10 Jun 2021 10:01:54 +0000 (+0200) Subject: fix Pipe ReadBuf usage X-Git-Url: https://git.proxmox.com/?p=pve-lxc-syscalld.git;a=commitdiff_plain;h=b5019f1a23e89af97776c79d5c85b082b2ab26a0 fix Pipe ReadBuf usage this wasn't advancing the ReadBuf state Signed-off-by: Wolfgang Bumiller --- diff --git a/src/io/pipe.rs b/src/io/pipe.rs index 3b312a8..e9d0b77 100644 --- a/src/io/pipe.rs +++ b/src/io/pipe.rs @@ -90,10 +90,15 @@ impl AsyncRead for Pipe { ) -> Poll> { self.fd.wrap_read(cx, || { let fd = self.as_raw_fd(); - let buf = buf.initialize_unfilled(); - let size = libc::size_t::try_from(buf.len()).map_err(io_err_other)?; - c_result!(unsafe { libc::read(fd, buf.as_mut_ptr() as *mut libc::c_void, size) }) - .map(|_| ()) + let mem = buf.initialize_unfilled(); + let size = libc::size_t::try_from(mem.len()).map_err(io_err_other)?; + c_result!(unsafe { libc::read(fd, mem.as_mut_ptr() as *mut libc::c_void, size) }).map( + |received| { + if received > 0 { + buf.advance(received as usize) + } + }, + ) }) } }