helper: Move service fds closing code to restore_one_helper()

Submitted by Kirill Tkhai on April 20, 2018, 10:10 a.m.

Details

Message ID 152421902247.18612.10063535209873615848.stgit@localhost.localdomain
State Accepted
Series "helper: Move service fds closing code to restore_one_helper()"
Commit 9ddf9a224a5fce08498163070f371d723de3abf5
Headers show

Commit Message

Kirill Tkhai April 20, 2018, 10:10 a.m.
There is no reasons we need this cleanup code in generic
restore_one_task(), so let's move it for better readability.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 criu/cr-restore.c |   20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index db913b2da..54216b8ea 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -1318,15 +1318,26 @@  static int wait_exiting_children(void)
  */
 static int restore_one_helper(void)
 {
+	int i;
+
 	if (prepare_fds(current))
 		return -1;
 
-	return wait_exiting_children();
+	if (wait_exiting_children())
+		return -1;
+
+	sfds_protected = false;
+	close_image_dir();
+	close_proc();
+	for (i = SERVICE_FD_MIN + 1; i < SERVICE_FD_MAX; i++)
+		close_service_fd(i);
+
+	return 0;
 }
 
 static int restore_one_task(int pid, CoreEntry *core)
 {
-	int i, ret;
+	int ret;
 
 	/* No more fork()-s => no more per-pid logs */
 
@@ -1336,11 +1347,6 @@  static int restore_one_task(int pid, CoreEntry *core)
 		ret = restore_one_zombie(core);
 	else if (current->pid->state == TASK_HELPER) {
 		ret = restore_one_helper();
-		sfds_protected = false;
-		close_image_dir();
-		close_proc();
-		for (i = SERVICE_FD_MIN + 1; i < SERVICE_FD_MAX; i++)
-			close_service_fd(i);
 	} else {
 		pr_err("Unknown state in code %d\n", (int)core->tc->task_state);
 		ret = -1;

Comments

Andrey Vagin April 26, 2018, 11:30 p.m.
Applied, thanks!

On Fri, Apr 20, 2018 at 01:10:22PM +0300, Kirill Tkhai wrote:
> There is no reasons we need this cleanup code in generic
> restore_one_task(), so let's move it for better readability.
> 
> Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
> ---
>  criu/cr-restore.c |   20 +++++++++++++-------
>  1 file changed, 13 insertions(+), 7 deletions(-)
> 
> diff --git a/criu/cr-restore.c b/criu/cr-restore.c
> index db913b2da..54216b8ea 100644
> --- a/criu/cr-restore.c
> +++ b/criu/cr-restore.c
> @@ -1318,15 +1318,26 @@ static int wait_exiting_children(void)
>   */
>  static int restore_one_helper(void)
>  {
> +	int i;
> +
>  	if (prepare_fds(current))
>  		return -1;
>  
> -	return wait_exiting_children();
> +	if (wait_exiting_children())
> +		return -1;
> +
> +	sfds_protected = false;
> +	close_image_dir();
> +	close_proc();
> +	for (i = SERVICE_FD_MIN + 1; i < SERVICE_FD_MAX; i++)
> +		close_service_fd(i);
> +
> +	return 0;
>  }
>  
>  static int restore_one_task(int pid, CoreEntry *core)
>  {
> -	int i, ret;
> +	int ret;
>  
>  	/* No more fork()-s => no more per-pid logs */
>  
> @@ -1336,11 +1347,6 @@ static int restore_one_task(int pid, CoreEntry *core)
>  		ret = restore_one_zombie(core);
>  	else if (current->pid->state == TASK_HELPER) {
>  		ret = restore_one_helper();
> -		sfds_protected = false;
> -		close_image_dir();
> -		close_proc();
> -		for (i = SERVICE_FD_MIN + 1; i < SERVICE_FD_MAX; i++)
> -			close_service_fd(i);
>  	} else {
>  		pr_err("Unknown state in code %d\n", (int)core->tc->task_state);
>  		ret = -1;
>