]> git.proxmox.com Git - pve-lxc-syscalld.git/commitdiff
fix Pipe ReadBuf usage
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 10 Jun 2021 10:01:54 +0000 (12:01 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 10 Jun 2021 10:01:55 +0000 (12:01 +0200)
this wasn't advancing the ReadBuf state

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
src/io/pipe.rs

index 3b312a88846230c376b8239e01800396ae4582d6..e9d0b77c10f94fc10aaf3cad4657b517754d9f54 100644 (file)
@@ -90,10 +90,15 @@ impl<RW: rw_traits::HasRead> AsyncRead for Pipe<RW> {
     ) -> Poll<io::Result<()>> {
         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)
+                    }
+                },
+            )
         })
     }
 }