Since haproxy 1.4.9, combining option httpclose and option
http-pretend-keepalive can leave the connections opened until the backend
keep-alive timeout is reached, providing bad performances.
The same can occur when the proxy is in tunnel mode.

This patch ensures that the server side connection is closed after the
response and ignore http-pretend-keepalive in tunnel mode.
---
 src/proto_http.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/proto_http.c b/src/proto_http.c
index 3ea4c8a..bcae5d8 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -3064,7 +3064,8 @@ int http_process_req_common(struct session *s, struct 
buffer *req, int an_bit, s
 
                if ((s->fe->options|s->be->options) & PR_O_KEEPALIVE)
                        tmp = TX_CON_WANT_KAL;
-               if ((s->fe->options|s->be->options) & PR_O_SERVER_CLO)
+               if ((s->fe->options|s->be->options) & PR_O_SERVER_CLO ||
+                   ((s->fe->options2|s->be->options2) & PR_O2_FAKE_KA))
                        tmp = TX_CON_WANT_SCL;
                if ((s->fe->options|s->be->options) & PR_O_FORCE_CLO)
                        tmp = TX_CON_WANT_CLO;
@@ -3541,8 +3542,7 @@ int http_process_request(struct session *s, struct buffer 
*req, int an_bit)
 
        /* 11: add "Connection: close" or "Connection: keep-alive" if needed 
and not yet set. */
        if (((txn->flags & TX_CON_WANT_MSK) != TX_CON_WANT_TUN) ||
-           ((s->fe->options|s->be->options) & PR_O_HTTP_CLOSE) ||
-           ((s->fe->options2|s->be->options2) & PR_O2_FAKE_KA)) {
+           ((s->fe->options|s->be->options) & PR_O_HTTP_CLOSE)) {
                unsigned int want_flags = 0;
 
                if (txn->flags & TX_REQ_VER_11) {
-- 
1.7.2.3


Reply via email to