[pbs-devel] [PATCH proxmox-backup v3 1/7] server: refactor abort_local_worker

Dominik Csapak d.csapak at proxmox.com
Fri Sep 17 13:56:01 CEST 2021


we'll need this outside the module

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 src/server/worker_task.rs | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/server/worker_task.rs b/src/server/worker_task.rs
index 2ef8ba9d..c4696a2f 100644
--- a/src/server/worker_task.rs
+++ b/src/server/worker_task.rs
@@ -102,9 +102,8 @@ pub fn register_task_control_commands(
     commando_sock.register_command("worker-task-abort".into(), move |args| {
         let upid = get_upid(args)?;
 
-        if let Some(ref worker) = WORKER_TASK_LIST.lock().unwrap().get(&upid.task_id) {
-            worker.request_abort();
-        }
+        abort_local_worker(upid);
+
         Ok(Value::Null)
     })?;
     commando_sock.register_command("worker-task-status".into(), move |args| {
@@ -841,3 +840,10 @@ pub async fn wait_for_local_worker(upid_str: &str) -> Result<(), Error> {
     }
     Ok(())
 }
+
+/// Request abort of a local worker (if existing and running)
+pub fn abort_local_worker(upid: UPID) {
+    if let Some(ref worker) = WORKER_TASK_LIST.lock().unwrap().get(&upid.task_id) {
+        worker.request_abort();
+    }
+}
-- 
2.30.2






More information about the pbs-devel mailing list