]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[BUG] http: fix http-pretend-keepalive and httpclose/tunnel mode
authorCyril Bonté <cyril.bonte@free.fr>
Wed, 29 Dec 2010 08:36:56 +0000 (09:36 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 29 Dec 2010 14:24:48 +0000 (15:24 +0100)
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

index 4e9f2065d791bc58cb8d8bbdb2c81e4310b23a02..bcda01e23b1d7ed2fceba21a43e5b483e1e5c139 100644 (file)
@@ -3096,7 +3096,8 @@ int http_process_req_common(struct session *s, struct buffer *req, int an_bit, s
             (s->be->options & (PR_O_KEEPALIVE|PR_O_SERVER_CLO|PR_O_HTTP_CLOSE|PR_O_FORCE_CLO)))) {
                int tmp = TX_CON_WANT_TUN;
 
-               if ((s->fe->options|s->be->options) & PR_O_KEEPALIVE)
+               if ((s->fe->options|s->be->options) & PR_O_KEEPALIVE ||
+                   ((s->fe->options2|s->be->options2) & PR_O2_FAKE_KA))
                        tmp = TX_CON_WANT_KAL;
                if ((s->fe->options|s->be->options) & PR_O_SERVER_CLO)
                        tmp = TX_CON_WANT_SCL;
@@ -3123,8 +3124,7 @@ int http_process_req_common(struct session *s, struct buffer *req, int an_bit, s
                     (txn->flags & TX_CON_WANT_MSK) == TX_CON_WANT_SCL) &&
                    ((txn->flags & TX_HDR_CONN_CLO) ||                         /* "connection: close" */
                     (txn->flags & (TX_REQ_VER_11|TX_HDR_CONN_KAL)) == 0 ||    /* no "connection: k-a" in 1.0 */
-                    (((s->fe->options|s->be->options) & PR_O_HTTP_CLOSE) &&   /* httpclose without pretend-ka... */
-                     1/*!((s->fe->options2|s->be->options2) & PR_O2_FAKE_KA)*/) || /* ... +any = forceclose */
+                    ((s->fe->options|s->be->options) & PR_O_HTTP_CLOSE) ||    /* httpclose+any = forceclose */
                     !(txn->flags & TX_REQ_XFER_LEN) ||                        /* no length known => close */
                     s->fe->state == PR_STSTOPPED))                            /* frontend is stopping */
                    txn->flags = (txn->flags & ~TX_CON_WANT_MSK) | TX_CON_WANT_CLO;
@@ -3581,8 +3581,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) {