From 25da342f75d2315a294d9ec18550c9639189cdcd Mon Sep 17 00:00:00 2001 From: Gao feng Date: Thu, 12 Nov 2015 23:26:58 +0800 Subject: [PATCH] introduce hyper_free_container Signed-off-by: Gao feng --- src/container.c | 20 +++++++++++++------- src/container.h | 1 + 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/container.c b/src/container.c index beb6b3d..f376e84 100644 --- a/src/container.c +++ b/src/container.c @@ -599,18 +599,13 @@ struct hyper_container *hyper_find_container(struct hyper_pod *pod, char *id) return NULL; } -void hyper_cleanup_container(struct hyper_container *c) +void hyper_free_container(struct hyper_container *c) { int i; struct volume *vol; struct env *env; struct fsmap *map; struct sysctl *sys; - char root[512]; - - sprintf(root, "/tmp/hyper/%s/devpts/", c->id); - if (umount(root) < 0 && umount2(root, MNT_DETACH)) - perror("umount devpts failed"); free(c->id); free(c->rootfs); @@ -646,7 +641,6 @@ void hyper_cleanup_container(struct hyper_container *c) free(map->path); } free(c->maps); - close(c->ns); free(c->exec.id); for (i = 0; i < c->exec.argc; i++) { @@ -656,6 +650,18 @@ void hyper_cleanup_container(struct hyper_container *c) free(c->exec.argv); } +void hyper_cleanup_container(struct hyper_container *c) +{ + char root[512]; + + sprintf(root, "/tmp/hyper/%s/devpts/", c->id); + if (umount(root) < 0 && umount2(root, MNT_DETACH)) + perror("umount devpts failed"); + + close(c->ns); + hyper_free_container(c); +} + void hyper_cleanup_containers(struct hyper_pod *pod) { int i; diff --git a/src/container.h b/src/container.h index 85e5575..1da5327 100644 --- a/src/container.h +++ b/src/container.h @@ -53,5 +53,6 @@ int hyper_start_container(struct hyper_container *container, struct hyper_container *hyper_find_container(struct hyper_pod *pod, char *id); void hyper_cleanup_container(struct hyper_container *container); void hyper_cleanup_containers(struct hyper_pod *pod); +void hyper_free_container(struct hyper_container *c); #endif