[PATCH 5/6] [RFC] user-cr: restart: Replace phantom pointer with index

Matt Helsley matthltc at us.ibm.com
Mon Feb 8 13:57:22 PST 2010


Signed-off-by: Matt Helsley <matthltc at us.ibm.com>
---
 restart.c |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/restart.c b/restart.c
index b0e87f0..e89bf42 100644
--- a/restart.c
+++ b/restart.c
@@ -210,7 +210,7 @@ struct task {
 	int prev_sib;
 	struct task *creator;
 
-	struct task *phantom;	/* pointer to place-holdler task (if any) */
+	int phantom;	/* index of place-holdler task (if any) */
 
 	pid_t pid;		/* process IDs, our bread-&-butter */
 	pid_t ppid;
@@ -1210,8 +1210,8 @@ static int ckpt_build_tree(void)
 			ckpt_dbg_cont(" next %d", ctx.tasks_arr[task->next_sib].pid);
 		if (task->prev_sib > -1)
 			ckpt_dbg_cont(" prev %d", ctx.tasks_arr[task->prev_sib].pid);
-		if (task->phantom)
-			ckpt_dbg_cont(" placeholder %d", task->phantom->pid);
+		if (task->phantom > -1)
+			ckpt_dbg_cont(" placeholder %d", ctx.tasks_arr[task->phantom].pid);
 		ckpt_dbg_cont(" %c%c%c%c%c%c",
 		       (task->flags & TASK_THREAD) ? 'T' : ' ',
 		       (task->flags & TASK_SIBLING) ? 'P' : ' ',
@@ -1251,7 +1251,7 @@ static int ckpt_setup_task(pid_t pid, pid_t ppid)
 	task->next_sib = -1;
 	task->prev_sib = -1;
 	task->creator = NULL;
-	task->phantom = NULL;
+	task->phantom = -1;
 
 	task->rpid = -1;
 
@@ -1388,7 +1388,7 @@ static int ckpt_init_tree(void)
 		task->next_sib = -1;
 		task->prev_sib = -1;
 		task->creator = NULL;
-		task->phantom = NULL;
+		task->phantom = -1;
 
 		task->rpid = -1;
 
@@ -1581,10 +1581,10 @@ static int ckpt_set_creator(struct task *task)
 	} else if (task->ppid == 1) {
 		/* (non-session-leader) orphan: creator is dummy */
 		ckpt_dbg("pid %d: orphan session %d\n", task->pid, task->sid);
-		if (!session->phantom)
+		if (session->phantom < 0)
 			if (ckpt_placeholder_task(task) < 0)
 				return -1;
-		creator = session->phantom;
+		creator = &ctx.tasks_arr[session->phantom];
 	} else {
 		/* first make sure we know the session's creator */
 		if (!session->creator) {
@@ -1662,7 +1662,7 @@ static int ckpt_placeholder_task(struct task *task)
 	holder->next_sib = -1;
 	holder->prev_sib = -1;
 	holder->creator = NULL;
-	holder->phantom = NULL;
+	holder->phantom = -1;
 
 	holder->rpid = -1;
 
@@ -1671,8 +1671,8 @@ static int ckpt_placeholder_task(struct task *task)
 		holder->next_sib = session->children;
 		ctx.tasks_arr[session->children].prev_sib = holder->index;
 	}
-	session->children = holder->index;/* = ctx.tasks_nr ?? */
-	session->phantom = holder;
+	session->children = holder->index;/* = ctx.tasks_nr */
+	session->phantom = holder->index;
 
 	/* reparent entry if necssary */
 	if (task->next_sib > -1)
-- 
1.6.3.3



More information about the Containers mailing list