[Devel] [PATCH 4/6] Move init_completion(&ctx->complete) to ctx_alloc

serue at us.ibm.com serue at us.ibm.com
Tue Nov 17 17:53:31 PST 2009


From: Serge E. Hallyn <serue at us.ibm.com>

That way we don't risk indirectly calling complete(&ctx->complete)
(through ckpt_err()) before ctx->complete has been initialized.

Signed-off-by: Serge E. Hallyn <serue at us.ibm.com>
---
 checkpoint/restart.c |    2 --
 checkpoint/sys.c     |    4 ++++
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/checkpoint/restart.c b/checkpoint/restart.c
index b684d7a..6cdefc9 100644
--- a/checkpoint/restart.c
+++ b/checkpoint/restart.c
@@ -1092,8 +1092,6 @@ static int wait_all_tasks_finish(struct ckpt_ctx *ctx)
 {
 	int ret;
 
-	init_completion(&ctx->complete);
-
 	BUG_ON(ctx->active_pid != -1);
 	ret = restore_activate_next(ctx);
 	if (ret < 0)
diff --git a/checkpoint/sys.c b/checkpoint/sys.c
index d64f5a7..bf66418 100644
--- a/checkpoint/sys.c
+++ b/checkpoint/sys.c
@@ -245,6 +245,8 @@ static struct ckpt_ctx *ckpt_ctx_alloc(int fd, unsigned long uflags,
 	INIT_LIST_HEAD(&ctx->pgarr_pool);
 	init_waitqueue_head(&ctx->waitq);
 	init_waitqueue_head(&ctx->ghostq);
+	if (kflags == CKPT_CTX_RESTART)
+		init_completion(&ctx->complete);
 
 #ifdef CONFIG_CHECKPOINT_DEBUG
 	INIT_LIST_HEAD(&ctx->task_status);
@@ -473,6 +475,8 @@ static void _ckpt_msg_appendv(struct ckpt_ctx *ctx, int err, char *fmt,
 
 	len += snprintf(&ctx->msg[len], CKPT_MSG_LEN-len, "[offset %lld]",
 			ctx->total);
+	if (len > CKPT_MSG_LEN)
+		goto full;
 	len += vsnprintf(&ctx->msg[len], CKPT_MSG_LEN-len, fmt, ap);
 	if (len > CKPT_MSG_LEN) {
 full:
-- 
1.6.1

_______________________________________________
Containers mailing list
Containers at lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers




More information about the Devel mailing list