Add remains when start container successfully

Signed-off-by: Gao feng <omarapazanadi@gmail.com>
This commit is contained in:
Gao feng
2015-11-16 12:10:01 +08:00
parent 0c997dbe85
commit b7c88467e2
4 changed files with 10 additions and 14 deletions
+1 -7
View File
@@ -545,13 +545,7 @@ int hyper_release_exec(struct hyper_exec *exec,
fprintf(stdout, "%s container init exited, type %d, remains %d, policy %d\n",
__func__, pod->type, pod->remains, pod->policy);
if (exec->init == 2) { // dynamic container
struct hyper_container *c = container_of(exec, struct hyper_container, exec);
// TODO send finish of this container and full cleanup
hyper_cleanup_container(c);
return 0;
}
// TODO send finish of this container and full cleanup
if (--pod->remains > 0)
return 0;
+1
View File
@@ -51,6 +51,7 @@ struct hyper_pod {
uint32_t e_num;
uint32_t d_num;
uint32_t type;
/* how many containers are running */
uint32_t remains;
uint8_t policy;
int efd;
+8 -5
View File
@@ -457,6 +457,8 @@ int hyper_start_container_stage0(struct hyper_container *c, struct hyper_pod *po
goto out;
}
/* container process is spawned and ready to execute */
pod->remains++;
ret = 0;
out:
close(arg.ctl_pipe[0]);
@@ -696,8 +698,10 @@ static int hyper_new_container(char *json, int length)
fprintf(stdout, "call hyper_new_container, json %s, len %d\n", json, length);
if (!pod->init_pid)
if (!pod->init_pid) {
fprintf(stdout, "the pod is not created yet\n");
return -1;
}
c = hyper_parse_new_container(pod, json, length);
if (c == NULL) {
@@ -705,15 +709,14 @@ static int hyper_new_container(char *json, int length)
return -1;
}
list_add_tail(&c->list, &pod->containers);
ret = hyper_start_container_stage0(c, pod);
if (ret < 0) {
//TODO full grace cleanup
hyper_cleanup_container(c);
return ret;
}
list_add_tail(&c->list, &pod->containers);
return 0;
return ret;
}
static int hyper_cmd_write_file(char *json, int length)
@@ -1114,7 +1117,7 @@ static int hyper_channel_handle(struct hyper_event *de, uint32_t len)
hyper_print_uptime();
break;
case STOPPOD:
ret = hyper_stop_pod(pod);
hyper_stop_pod(pod);
return 0;
//break;
case DESTROYPOD:
-2
View File
@@ -469,7 +469,6 @@ static int hyper_parse_containers(struct hyper_pod *pod, char *json, jsmntok_t *
i += next;
}
pod->remains = c_num;
return i;
fail:
list_for_each_entry_safe(c, n, &pod->containers, list)
@@ -733,7 +732,6 @@ realloc:
if (hyper_parse_container(pod, &c, json, toks) < 0)
goto fail;
c->exec.init = 2; // dynamic container type
free(toks);
return c;