2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-30 13:58:34 +00:00

rstore: Invert switch_restore_stage logic

Currentl it waits for previous stage to complete and starts the
next one. Now it starts the next one and waits for it to complete.
The latter way fits better into both -- the code and the head.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Pavel Emelyanov 2013-08-12 06:17:04 +04:00
parent 9b45833b81
commit e5534e8e3a

View File

@ -1255,15 +1255,8 @@ static void __restore_switch_stage(int next_stage)
static int restore_switch_stage(int next_stage)
{
int ret;
ret = restore_wait_inprogress_tasks();
if (ret)
return ret;
__restore_switch_stage(next_stage);
return 0;
return restore_wait_inprogress_tasks();
}
static int restore_root_task(struct pstree_item *init)
@ -1326,32 +1319,24 @@ static int restore_root_task(struct pstree_item *init)
timing_start(TIME_FORK);
__restore_switch_stage(CR_STATE_FORKING);
pr_info("Wait until all tasks are forked\n");
ret = restore_wait_inprogress_tasks();
if (ret)
ret = restore_switch_stage(CR_STATE_FORKING);
if (ret < 0)
goto out;
timing_stop(TIME_FORK);
__restore_switch_stage(CR_STATE_RESTORE_PGID);
ret = restore_switch_stage(CR_STATE_RESTORE_PGID);
if (ret < 0)
goto out;
pr_info("Wait until all tasks restored pgid\n");
ret = restore_switch_stage(CR_STATE_RESTORE);
if (ret < 0)
goto out;
pr_info("Wait until all tasks restored sigchld handlers\n");
ret = restore_switch_stage(CR_STATE_RESTORE_SIGCHLD);
if (ret < 0)
goto out;
pr_info("Wait until all tasks are restored\n");
ret = restore_wait_inprogress_tasks();
if (ret < 0)
goto out;
/* Restore SIGCHLD here to skip SIGCHLD from a network sctip */
ret = sigaction(SIGCHLD, &old_act, NULL);
if (ret < 0) {