From e3704f66ba93a6f4f3d09e3ef05a9d0ac6e2e48f Mon Sep 17 00:00:00 2001 From: Lai Jiangshan Date: Wed, 28 Sep 2016 15:27:01 +0800 Subject: [PATCH 1/2] remove unused hyper_cleanup_exec() Signed-off-by: Lai Jiangshan --- src/exec.c | 12 ------------ src/exec.h | 1 - 2 files changed, 13 deletions(-) diff --git a/src/exec.c b/src/exec.c index be17344..1ff50d3 100644 --- a/src/exec.c +++ b/src/exec.c @@ -846,15 +846,3 @@ int hyper_handle_exec_exit(struct hyper_pod *pod, int pid, uint8_t code) return 0; } - -void hyper_cleanup_exec(struct hyper_pod *pod) -{ - struct hyper_exec *exec, *next; - - list_for_each_entry_safe(exec, next, &pod->exec_head, list) { - fprintf(stdout, "send eof for exec seq %" PRIu64 "\n", exec->seq); - if (hyper_send_exec_eof(exec, 1) < 0 || - hyper_send_exec_code(exec, 1) < 0) - fprintf(stderr, "send eof failed\n"); - } -} diff --git a/src/exec.h b/src/exec.h index d283d32..8830cb6 100644 --- a/src/exec.h +++ b/src/exec.h @@ -51,6 +51,5 @@ int hyper_run_process(struct hyper_exec *e); struct hyper_exec *hyper_find_exec_by_pid(struct list_head *head, int pid); struct hyper_exec *hyper_find_exec_by_seq(struct hyper_pod *pod, uint64_t seq); int hyper_handle_exec_exit(struct hyper_pod *pod, int pid, uint8_t code); -void hyper_cleanup_exec(struct hyper_pod *pod); #endif From 22cfaea4d284986d4a05e055c2e0cc88d55a1477 Mon Sep 17 00:00:00 2001 From: Lai Jiangshan Date: Wed, 28 Sep 2016 15:35:57 +0800 Subject: [PATCH 2/2] remove block out from send_exec_finishing() Signed-off-by: Lai Jiangshan --- src/exec.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/src/exec.c b/src/exec.c index 1ff50d3..3d1ec3b 100644 --- a/src/exec.c +++ b/src/exec.c @@ -26,7 +26,7 @@ static int hyper_release_exec(struct hyper_exec *); static void hyper_exec_process(struct hyper_exec *exec); -static int send_exec_finishing(uint64_t seq, int len, int code, int block) +static int send_exec_finishing(uint64_t seq, int len, int code) { struct hyper_buf *buf = &ctl.tty.wbuf; @@ -50,27 +50,17 @@ static int send_exec_finishing(uint64_t seq, int len, int code, int block) buf->data[buf->get + 12] = code; buf->get += len; - if (!block) { - hyper_modify_event(ctl.efd, &ctl.tty, EPOLLIN | EPOLLOUT); - return 0; - } - - if (hyper_setfd_block(ctl.tty.fd) < 0 || - hyper_send_data(ctl.tty.fd, buf->data, buf->get) < 0 || - hyper_setfd_nonblock(ctl.tty.fd) < 0) { - fprintf(stderr, "send eof failed\n"); - return -1; - } + hyper_modify_event(ctl.efd, &ctl.tty, EPOLLIN | EPOLLOUT); return 0; } -static int hyper_send_exec_eof(struct hyper_exec *exec, int block) { - return send_exec_finishing(exec->seq, 12, -1, block); +static int hyper_send_exec_eof(struct hyper_exec *exec) { + return send_exec_finishing(exec->seq, 12, -1); } -static int hyper_send_exec_code(struct hyper_exec *exec, int block) { - return send_exec_finishing(exec->seq, 13, exec->code, block); +static int hyper_send_exec_code(struct hyper_exec *exec) { + return send_exec_finishing(exec->seq, 13, exec->code); } static void pts_hup(struct hyper_event *de, int efd, struct hyper_exec *exec) @@ -701,9 +691,9 @@ static int hyper_release_exec(struct hyper_exec *exec) list_del_init(&exec->list); - hyper_send_exec_eof(exec, 0); + hyper_send_exec_eof(exec); - hyper_send_exec_code(exec, 0); + hyper_send_exec_code(exec); fprintf(stdout, "%s exit code %" PRIu8"\n", __func__, exec->code); if (exec->init) {