server: refactor abort_local_worker

we'll need this outside the module

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Dominik Csapak 2021-09-21 12:11:12 +02:00 committed by Thomas Lamprecht
parent 84af82e8cf
commit 3f742f952a

View File

@ -100,9 +100,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| {
@ -828,3 +827,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();
}
}