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,9 +80,11 @@ 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> {
let error = self.error.lock().unwrap(); { // limit lock scope
if let Some(ref msg) = *error { let error = self.error.lock().unwrap();
return Err(format_err!("{}", msg)); if let Some(ref msg) = *error {
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)
} }