diff --git a/src/connector.c b/src/connector.c index ffaac679..5393ae1f 100644 --- a/src/connector.c +++ b/src/connector.c @@ -470,7 +470,7 @@ void *receiver(void *arg) for (i = 0; i < serverfds; i++) { /* The small values will be less than the first client ids */ event.data.u64 = i; - event.events = EPOLLIN; + event.events = EPOLLIN | EPOLLRDHUP; ret = epoll_ctl(epfd, EPOLL_CTL_ADD, cdata->serverfd[i], &event); if (ret < 0) { LOGEMERG("FATAL: Failed to add epfd %d to epoll_ctl", epfd); diff --git a/src/generator.c b/src/generator.c index 3a3989fe..a62a273e 100644 --- a/src/generator.c +++ b/src/generator.c @@ -1740,7 +1740,7 @@ out: } } else { keep_sockalive(cs->fd); - event.events = EPOLLIN; + event.events = EPOLLIN | EPOLLRDHUP; event.data.ptr = proxi; /* Add this connsock_t to the epoll list */ if (unlikely(epoll_ctl(epfd, EPOLL_CTL_ADD, cs->fd, &event) == -1)) { @@ -1994,7 +1994,7 @@ static void *proxy_recv(void *arg) if (likely(ret > 0)) { subproxy = event.data.ptr; cs = &subproxy->cs; - if (event.events & EPOLLHUP) + if (event.events & (EPOLLHUP | EPOLLERR | EPOLLRDHUP)) ret = -1; else ret = read_socket_line(cs, 5); @@ -2063,7 +2063,7 @@ static void *userproxy_recv(void *arg) } proxy = event.data.ptr; cs = &proxy->cs; - if (event.events & EPOLLHUP) { + if (event.events & (EPOLLHUP | EPOLLERR | EPOLLRDHUP)) { LOGNOTICE("Proxy %d:%d %s hung up in epoll_wait", proxy->id, proxy->subid, proxy->url); disable_subproxy(gdata, proxy->parent, proxy);