From 44d6029e54b102d1b82ff01004bc672547f443a5 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 19 Sep 2016 23:38:01 +1000 Subject: [PATCH] Handle upstream pools sending messages and then closing sockets immediately afterwards (eg after a redirect.) --- src/generator.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/generator.c b/src/generator.c index dc735b23..cb33cd8f 100644 --- a/src/generator.c +++ b/src/generator.c @@ -2100,12 +2100,15 @@ static void *proxy_recv(void *arg) /* Serialise messages from here once we have a cs by * holding the semaphore. */ cksem_wait(&cs->sem); - if (event.events & (EPOLLHUP | EPOLLERR | EPOLLRDHUP)) - ret = -1; - else { + /* Process any messages before checking for errors in + * case a message is sent and then the socket + * immediately closed. + */ + if (event.events & EPOLLIN) { timeout = 30; ret = read_socket_line(cs, &timeout); - } + } else if (event.events & (EPOLLHUP | EPOLLERR | EPOLLRDHUP)) + ret = -1; } if (ret < 1) { LOGNOTICE("Proxy %d:%d %s failed to epoll/read_socket_line in proxy_recv",