[CRIU] [PATCH cr 9/9] cr-restore: unlock connections at the last moment

Andrey Vagin avagin at openvz.org
Mon Sep 17 03:50:14 EDT 2012


Restore must not fail after unlocking connections.

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 cr-restore.c |   22 ++++++++++++----------
 net.c        |    1 +
 sk-tcp.c     |    2 --
 3 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/cr-restore.c b/cr-restore.c
index 98cfd34..762837e 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -904,6 +904,18 @@ static int restore_root_task(struct pstree_item *init, struct cr_options *opts)
 	futex_wait_while_gt(&task_entries->nr_in_progress, 0);
 	ret = (int)futex_get(&task_entries->nr_in_progress);
 
+	futex_set_and_wake(&task_entries->nr_in_progress, task_entries->nr);
+	futex_set_and_wake(&task_entries->start, CR_STATE_RESTORE_SIGCHLD);
+	futex_wait_until(&task_entries->nr_in_progress, 0);
+
+	/* Restore SIGCHLD here to skip SIGCHLD from a network sctip */
+	ret = sigaction(SIGCHLD, &old_act, NULL);
+	if (ret < 0) {
+		pr_perror("sigaction() failed\n");
+		goto out;
+	}
+
+	network_unlock();
 out:
 	if (ret < 0) {
 		struct pstree_item *pi;
@@ -921,16 +933,6 @@ out:
 		return 1;
 	}
 
-	futex_set_and_wake(&task_entries->nr_in_progress, task_entries->nr);
-	futex_set_and_wake(&task_entries->start, CR_STATE_RESTORE_SIGCHLD);
-	futex_wait_until(&task_entries->nr_in_progress, 0);
-
-	ret = sigaction(SIGCHLD, &old_act, NULL);
-	if (ret < 0) {
-		pr_perror("sigaction() failed\n");
-		return -1;
-	}
-
 	pr_info("Go on!!!\n");
 	futex_set_and_wake(&task_entries->start, CR_STATE_COMPLETE);
 
diff --git a/net.c b/net.c
index 96fb2ca..977544e 100644
--- a/net.c
+++ b/net.c
@@ -424,6 +424,7 @@ void network_unlock(void)
 
 	if  (!(opts.namespaces_flags & CLONE_NEWNET)) {
 		tcp_unlock_all();
+		tcp_unlock_connections();
 
 		return;
 	}
diff --git a/sk-tcp.c b/sk-tcp.c
index ec3f6b8..90ea4fb 100644
--- a/sk-tcp.c
+++ b/sk-tcp.c
@@ -534,8 +534,6 @@ int restore_one_tcp(int fd, struct inet_sk_info *ii)
 	if (rst_tcp_socks_add(fd))
 		return -1;
 
-	nf_unlock_connection_info(ii);
-
 	if (restore_tcp_conn_state(fd, ii))
 		return -1;
 
-- 
1.7.1



More information about the CRIU mailing list