pxar_backup_stream.rs: limit lock scope to avoid blocking forever

This commit is contained in:
Dietmar Maurer 2019-07-24 11:30:43 +02:00
parent 684233aa3b
commit 6c3c9bceb5

View File

@ -80,10 +80,12 @@ impl Stream for PxarBackupStream {
type Error = Error; type Error = Error;
fn poll(&mut self) -> Poll<Option<Vec<u8>>, Error> { fn poll(&mut self) -> Poll<Option<Vec<u8>>, Error> {
{ // limit lock scope
let error = self.error.lock().unwrap(); let error = self.error.lock().unwrap();
if let Some(ref msg) = *error { if let Some(ref msg) = *error {
return Err(format_err!("{}", msg)); return Err(format_err!("{}", msg));
} }
}
self.stream.as_mut().unwrap().poll().map_err(Error::from) self.stream.as_mut().unwrap().poll().map_err(Error::from)
} }
} }