Commit 89d10280 authored by Andrei Vagin's avatar Andrei Vagin Committed by Pavel Emelyanov

restore: handle errors of restore_wait_other_tasks

In a error case, task_entries->nr_in_progress is set to -1
and we have to handle this case.
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 181c44aa
......@@ -162,12 +162,12 @@ static inline int stage_current_participants(int next_stage)
return -1;
}
static int restore_wait_inprogress_tasks()
static int __restore_wait_inprogress_tasks(int participants)
{
int ret;
futex_t *np = &task_entries->nr_in_progress;
futex_wait_while_gt(np, 0);
futex_wait_while_gt(np, participants);
ret = (int)futex_get(np);
if (ret < 0) {
set_cr_errno(get_task_cr_err());
......@@ -177,6 +177,22 @@ static int restore_wait_inprogress_tasks()
return 0;
}
static int restore_wait_inprogress_tasks()
{
return __restore_wait_inprogress_tasks(0);
}
/* Wait all tasks except the current one */
static int restore_wait_other_tasks()
{
int participants, stage;
stage = futex_get(&task_entries->start);
participants = stage_current_participants(stage);
return __restore_wait_inprogress_tasks(participants);
}
static inline void __restore_switch_stage_nw(int next_stage)
{
futex_set(&task_entries->nr_in_progress,
......@@ -198,18 +214,6 @@ static int restore_switch_stage(int next_stage)
return restore_wait_inprogress_tasks();
}
/* Wait all tasks except the current one */
static void restore_wait_other_tasks()
{
int participants, stage;
stage = futex_get(&task_entries->start);
participants = stage_current_participants(stage);
futex_wait_while_gt(&task_entries->nr_in_progress,
participants);
}
static int restore_finish_ns_stage(int from, int to)
{
if (root_ns_mask)
......@@ -1565,7 +1569,8 @@ static int restore_task_with_children(void *_arg)
*
* It means that all tasks entered into their namespaces.
*/
restore_wait_other_tasks();
if (restore_wait_other_tasks())
goto err;
fini_restore_mntns();
__restore_switch_stage(CR_STATE_RESTORE);
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment