fix Pipe ReadBuf usage

this wasn't advancing the ReadBuf state

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2021-06-10 12:01:54 +02:00
parent a8a175ea0b
commit b5019f1a23

View File

@ -90,10 +90,15 @@ impl<RW: rw_traits::HasRead> AsyncRead for Pipe<RW> {
) -> Poll<io::Result<()>> { ) -> Poll<io::Result<()>> {
self.fd.wrap_read(cx, || { self.fd.wrap_read(cx, || {
let fd = self.as_raw_fd(); let fd = self.as_raw_fd();
let buf = buf.initialize_unfilled(); let mem = buf.initialize_unfilled();
let size = libc::size_t::try_from(buf.len()).map_err(io_err_other)?; let size = libc::size_t::try_from(mem.len()).map_err(io_err_other)?;
c_result!(unsafe { libc::read(fd, buf.as_mut_ptr() as *mut libc::c_void, size) }) c_result!(unsafe { libc::read(fd, mem.as_mut_ptr() as *mut libc::c_void, size) }).map(
.map(|_| ()) |received| {
if received > 0 {
buf.advance(received as usize)
}
},
)
}) })
} }
} }