From 2698e8a51438ca41ab9bd45ef34251f323fc26f3 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Mon, 20 May 2019 11:20:33 +0200 Subject: [PATCH] src/client/pxar_backup_stream.rs: close pipe inside drop --- src/client/pxar_backup_stream.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/client/pxar_backup_stream.rs b/src/client/pxar_backup_stream.rs index 484e7989..f7a57ca9 100644 --- a/src/client/pxar_backup_stream.rs +++ b/src/client/pxar_backup_stream.rs @@ -22,13 +22,14 @@ use crate::tools::wrapped_reader_stream::WrappedReaderStream; /// /// Note: The currect implementation is not fully ansync and can block. pub struct PxarBackupStream { - stream: WrappedReaderStream, + stream: Option>, child: Option>, } impl Drop for PxarBackupStream { fn drop(&mut self) { + self.stream = None; self.child.take().unwrap().join().unwrap(); } } @@ -52,7 +53,7 @@ impl PxarBackupStream { let pipe = unsafe { std::fs::File::from_raw_fd(rx) }; let stream = crate::tools::wrapped_reader_stream::WrappedReaderStream::new(pipe); - Ok(Self { stream, child: Some(child) }) + Ok(Self { stream: Some(stream), child: Some(child) }) } pub fn open(dirname: &Path, all_file_systems: bool, verbose: bool) -> Result { @@ -70,6 +71,6 @@ impl Stream for PxarBackupStream { type Error = Error; fn poll(&mut self) -> Poll>, Error> { - self.stream.poll().map_err(Error::from) + self.stream.as_mut().unwrap().poll().map_err(Error::from) } }