tools/fs: mark ReadDir as Send

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2019-02-14 12:33:20 +01:00
parent 62f2422f6a
commit 2cc90617dd

View File

@ -76,7 +76,7 @@ impl ReadDirEntry {
// This is simply a wrapper with a shorter type name mapping nix::Error to failure::Error. // This is simply a wrapper with a shorter type name mapping nix::Error to failure::Error.
/// Wrapper over a pair of `nix::dir::Dir` and `nix::dir::Iter`, returned by `read_subdir()`. /// Wrapper over a pair of `nix::dir::Dir` and `nix::dir::Iter`, returned by `read_subdir()`.
pub struct ReadDir { pub struct ReadDir {
iter: Tied<Dir, Iterator<Item = nix::Result<dir::Entry>>>, iter: Tied<Dir, Iterator<Item = nix::Result<dir::Entry>> + Send>,
dir_fd: RawFd, dir_fd: RawFd,
} }
@ -100,7 +100,7 @@ pub fn read_subdir<P: ?Sized + nix::NixPath>(dirfd: RawFd, path: &P) -> Result<R
let dir = Dir::openat(dirfd, path, OFlag::O_RDONLY, Mode::empty())?; let dir = Dir::openat(dirfd, path, OFlag::O_RDONLY, Mode::empty())?;
let fd = dir.as_raw_fd(); let fd = dir.as_raw_fd();
let iter = Tied::new(dir, |dir| { let iter = Tied::new(dir, |dir| {
Box::new(unsafe { (*dir).iter() }) as Box<Iterator<Item = nix::Result<dir::Entry>>> Box::new(unsafe { (*dir).iter() }) as Box<Iterator<Item = nix::Result<dir::Entry>> + Send>
}); });
Ok(ReadDir { iter, dir_fd: fd }) Ok(ReadDir { iter, dir_fd: fd })
} }