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:
parent
e31ad5f195
commit
a90aad23a4
@ -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)
|
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 pstree_item *ns_reaper;
|
||||||
struct ns_id *ns, *tmp;
|
struct ns_id *ns, *tmp;
|
||||||
struct pid *pid;
|
struct pid *pid;
|
||||||
@ -2681,19 +2681,20 @@ static int do_create_pid_ns_helper(void *arg, int sk, pid_t unused_pid)
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
child = fork();
|
child = fork();
|
||||||
if (child < 0) {
|
if (!child) {
|
||||||
flock(lock_fd, LOCK_UN);
|
|
||||||
close(lock_fd);
|
|
||||||
pr_perror("Can't fork");
|
|
||||||
return -1;
|
|
||||||
} else if (!child) {
|
|
||||||
close(lock_fd);
|
close(lock_fd);
|
||||||
exit(pid_ns_helper(ns, sk));
|
exit(pid_ns_helper(ns, sk));
|
||||||
}
|
}
|
||||||
close(sk);
|
saved_errno = errno;
|
||||||
futex_set_and_wake(&ns->pid.helper_created, 1);
|
|
||||||
flock(lock_fd, LOCK_UN);
|
flock(lock_fd, LOCK_UN);
|
||||||
close(lock_fd);
|
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;
|
pid->real = child;
|
||||||
|
|
||||||
if (restore_ns(pid_ns_fd, &pid_ns_desc) < 0)
|
if (restore_ns(pid_ns_fd, &pid_ns_desc) < 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user