]> git.proxmox.com Git - proxmox-backup.git/commit - src/server/worker_task.rs
fix inserting of worker tasks
authorDominik Csapak <d.csapak@proxmox.com>
Wed, 27 May 2020 14:42:22 +0000 (16:42 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 28 May 2020 04:24:42 +0000 (06:24 +0200)
commit05d755b282816b4d9c98dd9510b4fd3af0a70eea
tree42cc0e8dc648ee0f483db1e4cee7ad3abe4a3de0
parent143b654550b235eb37266a4801b2a493bd66385c
fix inserting of worker tasks

when starting a new task, we do two things to keep track of tasks
(in that order):
* updating the 'active' file with a list of tasks with
  'update_active_workers'
* updating the WORKER_TASK_LIST

the second also updates the status of running tasks in the file by
checking if it is still running by checking the WORKER_TASK_LIST

since those two things are not locked, it can happend that
we update the file, and before updating the WORKER_TASK_LIST,
another thread calls update_active_workers and tries to
get the status from the task log, which won't have any data yet
so the status is 'unknown'

(we do not update that status ever, likely for performance reasons,
so we have to fix this here)

by switching the order of the two operations, we make sure that only
tasks reach the 'active' file which are inserted in the WORKER_TASK_LIST

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
src/server/worker_task.rs