fix possible missing eof data

It happend that pts_loop reads all of the data before the,
SIGCHLD signal being handled, so only hup handler will be triggered,
move the sending eof message to hup handler.

Signed-off-by: Gao feng <omarapazanadi@gmail.com>
This commit is contained in:
Gao feng
2015-09-23 23:07:22 +08:00
parent 88bb908c76
commit 749387bbfa
2 changed files with 15 additions and 7 deletions
+15 -6
View File
@@ -20,9 +20,23 @@
static void pts_hup(struct hyper_event *de, int efd)
{
struct hyper_pod *pod = de->ptr;
struct hyper_buf *buf = &ctl.tty.wbuf;
struct hyper_exec *exec = container_of(de, struct hyper_exec, e);
fprintf(stdout, "%s\n", __func__);
if (buf->get + 12 > buf->size) {
fprintf(stdout, "%s: tty buf full\n", __func__);
return;
}
/* no in event, no more data, send eof */
hyper_set_be64(buf->data + buf->get, exec->seq);
hyper_set_be32(buf->data + buf->get + 8, 12);
buf->get += 12;
hyper_modify_event(ctl.efd, &ctl.tty, EPOLLIN | EPOLLOUT);
hyper_release_exec(exec, pod);
}
@@ -45,12 +59,7 @@ static int pts_loop(struct hyper_event *de)
return -1;
}
if (!exec->exit && size != 0)
break;
/* container task exited, No more data from pts of container, release exec */
size = 0;
fprintf(stdout, "%s: get eof from pts of contaienr\n", __func__);
break;
}
hyper_set_be64(buf->data + buf->get, exec->seq);
-1
View File
@@ -1235,7 +1235,6 @@ static int hyper_loop(void)
if (hyper_handle_event(ctl.efd, &events[i]) < 0)
return -1;
}
hyper_modify_event(ctl.efd, &ctl.sig, EPOLLIN);
}
free(events);