[pbs-devel] [PATCH proxmox-backup 2/2] api2/pull: make pull worker abortable

Dominik Csapak d.csapak at proxmox.com
Tue Sep 15 11:15:01 CEST 2020


by selecting between the pull_future and the abort future

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 src/api2/pull.rs | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/api2/pull.rs b/src/api2/pull.rs
index fc13cf40..09e27a17 100644
--- a/src/api2/pull.rs
+++ b/src/api2/pull.rs
@@ -176,7 +176,13 @@ async fn pull (
 
         worker.log(format!("sync datastore '{}' start", store));
 
-        pull_store(&worker, &client, &src_repo, tgt_store.clone(), delete, userid).await?;
+        let pull_future = pull_store(&worker, &client, &src_repo, tgt_store.clone(), delete, userid);
+        let future = select!{
+            success = pull_future.fuse() => success,
+            abort = worker.abort_future().map(|_| Err(format_err!("pull aborted"))) => abort,
+        };
+
+        let _ = future?;
 
         worker.log(format!("sync datastore '{}' end", store));
 
-- 
2.20.1






More information about the pbs-devel mailing list