OpenVZ Forum


Home » Mailing lists » Devel » [PATCH 02/11] restart: cleanup setup/cleanup of freezer cgroups
[PATCH 02/11] restart: cleanup setup/cleanup of freezer cgroups [message #41562] Mon, 07 February 2011 17:21
Oren Laadan is currently offline  Oren Laadan
Messages: 71
Registered: August 2007
Member
From: *parallels.com
Signed-off-by: Oren Laadan <orenl@cs.columbia.edu>
---
restart.c | 22 ++++++++++------------
1 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/restart.c b/restart.c
index 8106fd6..195a892 100644
--- a/restart.c
+++ b/restart.c
@@ -359,35 +359,32 @@ static void sigint_handler(int sig)

static int freezer_prepare(struct ckpt_ctx *ctx)
{
- char *freezer;
int fd, ret;

#define FREEZER_THAWED "THAWED"

- freezer = malloc(strlen(ctx->args->freezer) + 32);
- if (!freezer) {
+ ctx->freezer = malloc(strlen(ctx->args->freezer) + 32);
+ if (!ctx->freezer) {
ckpt_perror("malloc freezer buf");
- return -1;
+ return ctx_set_errno(ctx);
}

- sprintf(freezer, "%s/freezer.state", ctx->args->freezer);
+ sprintf(ctx->freezer, "%s/freezer.state", ctx->args->freezer);

- fd = open(freezer, O_WRONLY, 0);
+ fd = open(ctx->freezer, O_WRONLY, 0);
if (fd < 0) {
ckpt_perror("freezer path");
- free(freezer);
- return -1;
+ return ctx_set_errno(ctx);
}
ret = write(fd, FREEZER_THAWED, sizeof(FREEZER_THAWED));
if (ret != sizeof(FREEZER_THAWED)) {
ckpt_perror("thawing freezer");
- free(freezer);
+ ctx_set_errno(ctx);
close(fd);
return -1;
}

- sprintf(freezer, "%s/tasks", ctx->args->freezer);
- ctx->freezer = freezer;
+ sprintf(ctx->freezer, "%s/tasks", ctx->args->freezer);
close(fd);
return 0;
}
@@ -400,13 +397,14 @@ static int freezer_register(struct ckpt_ctx *ctx, pid_t pid)
fd = open(ctx->freezer, O_WRONLY, 0);
if (fd < 0) {
ckpt_perror("freezer path");
- return -1;
+ return ctx_set_errno(ctx);
}

n = sprintf(pidstr, "%d", pid);
ret = write(fd, pidstr, n);
if (ret != n) {
ckpt_perror("adding pid %d to freezer");
+ ctx_set_errno(ctx);
close(fd);
return -1;
}
--
1.7.1

_______________________________________________
Containers mailing list
Containers@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containe rs
Previous Topic: [PATCH 01/11] Introduce ctx-&gt;error to improve error reporting
Next Topic: [PATCH 03/11] restart: make feeder a proper child instead of a thread
Goto Forum:
  


Current Time: Fri Sep 21 21:11:39 GMT 2018