[CRIU] [PATCH 1/3] namespace: Group unlocking/closing operations in do_create_pid_ns_helper()
Kirill Tkhai
ktkhai at virtuozzo.com
Thu May 11 07:55:04 PDT 2017
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 at virtuozzo.com>
---
criu/namespaces.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/criu/namespaces.c b/criu/namespaces.c
index 3d75317c1..7a38dfd4a 100644
--- a/criu/namespaces.c
+++ b/criu/namespaces.c
@@ -2690,19 +2690,18 @@ 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);
flock(lock_fd, LOCK_UN);
close(lock_fd);
+ if (child < 0) {
+ pr_perror("Can't fork");
+ goto err;
+ }
+ futex_set_and_wake(&ns->pid.helper_created, 1);
+ close(sk);
nr_pid_ns_helper_created++;
if (setns(pid_ns_fd, CLONE_NEWPID) < 0) {
More information about the CRIU
mailing list