From b428af978154c2659de987b99e72998778e457ee Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Tue, 20 Oct 2020 14:18:14 +0200 Subject: [PATCH] backup: avoid Transport endpoint is not connected error We simply supress the error message if the finish flag is set. --- src/api2/backup.rs | 16 +++++++++++++++- src/api2/backup/environment.rs | 6 ++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/api2/backup.rs b/src/api2/backup.rs index ca7af3c8..b56ddbdd 100644 --- a/src/api2/backup.rs +++ b/src/api2/backup.rs @@ -182,8 +182,22 @@ async move { http.http2_initial_connection_window_size(window_size); http.http2_max_frame_size(4*1024*1024); + let env3 = env2.clone(); http.serve_connection(conn, service) - .map_err(Error::from) + .map(move |result| { + match result { + Err(err) => { + // Avoid Transport endpoint is not connected (os error 107) + // fixme: find a better way to test for that error + if err.to_string().starts_with("connection error") && env3.finished() { + Ok(()) + } else { + Err(Error::from(err)) + } + } + Ok(()) => Ok(()), + } + }) }); let mut abort_future = abort_future .map(|_| Err(format_err!("task aborted"))); diff --git a/src/api2/backup/environment.rs b/src/api2/backup/environment.rs index 27497b24..dea3ca57 100644 --- a/src/api2/backup/environment.rs +++ b/src/api2/backup/environment.rs @@ -567,6 +567,12 @@ impl BackupEnvironment { Ok(()) } + /// Return true if the finished flag is set + pub fn finished(&self) -> bool { + let state = self.state.lock().unwrap(); + state.finished + } + /// Remove complete backup pub fn remove_backup(&self) -> Result<(), Error> { let mut state = self.state.lock().unwrap();