From: Cyril Bonté Date: Wed, 29 Dec 2010 08:36:56 +0000 (+0100) Subject: [BUG] http: fix http-pretend-keepalive and httpclose/tunnel mode X-Git-Tag: v1.5-dev8~338 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9ea2b9ac753697aed856b9a912b67a45c69bb8f8;p=thirdparty%2Fhaproxy.git [BUG] http: fix http-pretend-keepalive and httpclose/tunnel mode 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. --- diff --git a/src/proto_http.c b/src/proto_http.c index 4e9f2065d7..bcda01e23b 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -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) {