[CRIU] [PATCH 2/5] pstree: split alloc_pstree_helper

Andrey Vagin avagin at openvz.org
Tue Mar 15 16:11:12 PDT 2016


From: Andrew Vagin <avagin at virtuozzo.com>

Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
---
 criu/include/pstree.h |  1 +
 criu/pstree.c         | 14 +++++++++-----
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/criu/include/pstree.h b/criu/include/pstree.h
index 495258e..226d99a 100644
--- a/criu/include/pstree.h
+++ b/criu/include/pstree.h
@@ -66,6 +66,7 @@ extern struct pstree_item *__alloc_pstree_item(bool rst);
 #define alloc_pstree_item() __alloc_pstree_item(false)
 #define alloc_pstree_item_with_rst() __alloc_pstree_item(true)
 extern struct pstree_item *alloc_pstree_helper(void);
+extern void init_pstree_helper(struct pstree_item *ret);
 
 extern struct pstree_item *root_item;
 extern struct pstree_item *pstree_item_next(struct pstree_item *item);
diff --git a/criu/pstree.c b/criu/pstree.c
index 58391c7..bdf8ff6 100644
--- a/criu/pstree.c
+++ b/criu/pstree.c
@@ -222,16 +222,20 @@ struct pstree_item *__alloc_pstree_item(bool rst)
 	return item;
 }
 
+void init_pstree_helper(struct pstree_item *ret)
+{
+	ret->pid.state = TASK_HELPER;
+	rsti(ret)->clone_flags = CLONE_FILES | CLONE_FS;
+	task_entries->nr_helpers++;
+}
+
 struct pstree_item *alloc_pstree_helper(void)
 {
 	struct pstree_item *ret;
 
 	ret = alloc_pstree_item_with_rst();
-	if (ret) {
-		ret->pid.state = TASK_HELPER;
-		rsti(ret)->clone_flags = CLONE_FILES | CLONE_FS;
-		task_entries->nr_helpers++;
-	}
+	if (ret)
+		init_pstree_helper(ret);
 
 	return ret;
 }
-- 
2.5.0



More information about the CRIU mailing list