From e5534e8e3a6fd8b5ca2eebb71fb3a79ccfa24414 Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Mon, 12 Aug 2013 06:17:04 +0400 Subject: [PATCH] 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 --- cr-restore.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/cr-restore.c b/cr-restore.c index e6f5881c1..6fce1bbe4 100644 --- a/cr-restore.c +++ b/cr-restore.c @@ -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) {