Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit 5f4e90c

Browse files
committed
handle EPOLLRDHUP event
So that we know when runv closes a connection. Signed-off-by: Peng Tao <bergwolf@gmail.com>
1 parent 4d91dd9 commit 5f4e90c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/event.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ int hyper_init_event(struct hyper_event *he, struct hyper_event_ops *ops, void *
5454
int hyper_add_event(int efd, struct hyper_event *he, int flag)
5555
{
5656
struct epoll_event event = {
57-
.events = flag,
57+
.events = flag | EPOLLRDHUP,
5858
.data.ptr = he,
5959
};
6060

61-
he->flag = flag;
61+
he->flag = flag | EPOLLRDHUP;
6262
if (hyper_setfd_nonblock(he->fd) < 0) {
6363
perror("set fd nonblock failed");
6464
return -1;
@@ -77,14 +77,14 @@ int hyper_add_event(int efd, struct hyper_event *he, int flag)
7777
int hyper_modify_event(int efd, struct hyper_event *he, int flag)
7878
{
7979
struct epoll_event event = {
80-
.events = flag,
80+
.events = flag | EPOLLRDHUP,
8181
.data.ptr = he,
8282
};
8383

8484
if (he->flag == flag)
8585
return 0;
8686

87-
he->flag = flag;
87+
he->flag = flag | EPOLLRDHUP;
8888
fprintf(stdout, "%s modify event fd %d, %p, event %d\n",
8989
__func__, he->fd, he, flag);
9090

@@ -191,7 +191,7 @@ int hyper_handle_event(int efd, struct epoll_event *event)
191191
return he->ops->write(he, efd, event->events);
192192
}
193193

194-
if ((event->events & EPOLLHUP) || (event->events & EPOLLERR)) {
194+
if ((event->events & EPOLLHUP) || (event->events & EPOLLERR) || (event->events & EPOLLRDHUP)) {
195195
fprintf(stdout, "%s event EPOLLHUP or EPOLLERR, he %p, fd %d, %x\n",
196196
__func__, he, he->fd, event->events);
197197
if (he->ops->hup)

0 commit comments

Comments
 (0)