Browse Source

Check for epoll hangups fully

master
Con Kolivas 10 years ago
parent
commit
cb640b6ab2
  1. 2
      src/connector.c
  2. 6
      src/generator.c

2
src/connector.c

@ -470,7 +470,7 @@ void *receiver(void *arg)
for (i = 0; i < serverfds; i++) { for (i = 0; i < serverfds; i++) {
/* The small values will be less than the first client ids */ /* The small values will be less than the first client ids */
event.data.u64 = i; event.data.u64 = i;
event.events = EPOLLIN; event.events = EPOLLIN | EPOLLRDHUP;
ret = epoll_ctl(epfd, EPOLL_CTL_ADD, cdata->serverfd[i], &event); ret = epoll_ctl(epfd, EPOLL_CTL_ADD, cdata->serverfd[i], &event);
if (ret < 0) { if (ret < 0) {
LOGEMERG("FATAL: Failed to add epfd %d to epoll_ctl", epfd); LOGEMERG("FATAL: Failed to add epfd %d to epoll_ctl", epfd);

6
src/generator.c

@ -1740,7 +1740,7 @@ out:
} }
} else { } else {
keep_sockalive(cs->fd); keep_sockalive(cs->fd);
event.events = EPOLLIN; event.events = EPOLLIN | EPOLLRDHUP;
event.data.ptr = proxi; event.data.ptr = proxi;
/* Add this connsock_t to the epoll list */ /* Add this connsock_t to the epoll list */
if (unlikely(epoll_ctl(epfd, EPOLL_CTL_ADD, cs->fd, &event) == -1)) { 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)) { if (likely(ret > 0)) {
subproxy = event.data.ptr; subproxy = event.data.ptr;
cs = &subproxy->cs; cs = &subproxy->cs;
if (event.events & EPOLLHUP) if (event.events & (EPOLLHUP | EPOLLERR | EPOLLRDHUP))
ret = -1; ret = -1;
else else
ret = read_socket_line(cs, 5); ret = read_socket_line(cs, 5);
@ -2063,7 +2063,7 @@ static void *userproxy_recv(void *arg)
} }
proxy = event.data.ptr; proxy = event.data.ptr;
cs = &proxy->cs; 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, LOGNOTICE("Proxy %d:%d %s hung up in epoll_wait", proxy->id,
proxy->subid, proxy->url); proxy->subid, proxy->url);
disable_subproxy(gdata, proxy->parent, proxy); disable_subproxy(gdata, proxy->parent, proxy);

Loading…
Cancel
Save