[pbs-devel] [PATCH proxmox 2/2] rest-server: close race window when updating worker task count
Fabian Grünbichler
f.gruenbichler at proxmox.com
Fri Nov 29 14:13:29 CET 2024
this mimics how the count is updated when spawning a new task - the lock scope
needs to cover the count update itself, else there's a race when multiple
worker's log their result at the same time..
Co-developed-by: Dominik Csapak <d.csapak at proxmox.com>
Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
proxmox-rest-server/src/worker_task.rs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/proxmox-rest-server/src/worker_task.rs b/proxmox-rest-server/src/worker_task.rs
index 3ca93965..018d18c0 100644
--- a/proxmox-rest-server/src/worker_task.rs
+++ b/proxmox-rest-server/src/worker_task.rs
@@ -1023,7 +1023,8 @@ impl WorkerTask {
WORKER_TASK_LIST.lock().unwrap().remove(&self.upid.task_id);
let _ = self.setup.update_active_workers(None);
- set_worker_count(WORKER_TASK_LIST.lock().unwrap().len());
+ let lock = WORKER_TASK_LIST.lock().unwrap();
+ set_worker_count(lock.len());
}
/// Log a message.
--
2.39.5
More information about the pbs-devel
mailing list