restore: fix race in calculation of a number of zombies

Currently each task subtracts number of zombies from
task_entries->nr_threads without locks, so if two tasks will do this
operation concurrently, the result may be unpredictable.

https://github.com/xemul/criu/issues/13

Cc: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Andrew Vagin <avagin@openvz.org>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Andrew Vagin 2015-08-03 14:37:00 +03:00 committed by Pavel Emelyanov
parent 9d9518b852
commit f13ec96e58
3 changed files with 9 additions and 2 deletions

View file

@ -7,6 +7,7 @@
struct task_entries {
int nr_threads, nr_tasks, nr_helpers;
atomic_t nr_zombies;
futex_t nr_in_progress;
futex_t start;
atomic_t cr_err;