2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-29 13:28:27 +00:00

namespace: Group unlocking/closing operations in do_create_pid_ns_helper()

Group them for 1)error and 2)parent cases. This minimize the code
and will be used in next patches.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
Kirill Tkhai 2017-05-16 19:26:53 +03:00 committed by Andrei Vagin
parent e31ad5f195
commit a90aad23a4

View File

@ -2627,7 +2627,7 @@ static int pid_ns_helper(struct ns_id *ns, int sk)
static int do_create_pid_ns_helper(void *arg, int sk, pid_t unused_pid)
{
int pid_ns_fd, mnt_ns_fd, i, lock_fd, transport_fd;
int pid_ns_fd, mnt_ns_fd, i, lock_fd, transport_fd, saved_errno;
struct pstree_item *ns_reaper;
struct ns_id *ns, *tmp;
struct pid *pid;
@ -2681,19 +2681,20 @@ static int do_create_pid_ns_helper(void *arg, int sk, pid_t unused_pid)
goto err;
}
child = fork();
if (child < 0) {
flock(lock_fd, LOCK_UN);
close(lock_fd);
pr_perror("Can't fork");
return -1;
} else if (!child) {
if (!child) {
close(lock_fd);
exit(pid_ns_helper(ns, sk));
}
close(sk);
futex_set_and_wake(&ns->pid.helper_created, 1);
saved_errno = errno;
flock(lock_fd, LOCK_UN);
close(lock_fd);
if (child < 0) {
errno = saved_errno;
pr_perror("Can't fork");
goto err;
}
close(sk);
futex_set_and_wake(&ns->pid.helper_created, 1);
pid->real = child;
if (restore_ns(pid_ns_fd, &pid_ns_desc) < 0)