]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: streams: Try to L7 retry before aborting the connection.
authorOlivier Houchard <ohouchard@haproxy.com>
Fri, 17 May 2019 13:40:49 +0000 (15:40 +0200)
committerOlivier Houchard <cognet@ci0.org>
Fri, 17 May 2019 13:49:21 +0000 (15:49 +0200)
In htx_wait_for_response, in case of error, attempt a L7 retry before
aborting the connection if the TX_NOT_FIRST flag is set.
If we don't do that, then we wouldn't attempt L7 retries after the first
request, or if we use HTTP/2, as with HTTP/2 that flag is always set.

src/proto_htx.c

index e7341c1ae1261ca46ff030b3f5450d2ddf834972..6393eed6a2ae5a19a33597dd3ac9df06ce118c11 100644 (file)
@@ -1496,9 +1496,6 @@ int htx_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
                if (rep->flags & CF_READ_ERROR) {
                        struct connection *conn = NULL;
 
-                       if (txn->flags & TX_NOT_FIRST)
-                               goto abort_keep_alive;
-
                        if (objt_cs(s->si[1].end))
                                conn = objt_cs(s->si[1].end)->conn;
 
@@ -1514,6 +1511,9 @@ int htx_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
                                        return 0;
                        }
 
+                       if (txn->flags & TX_NOT_FIRST)
+                               goto abort_keep_alive;
+
                        _HA_ATOMIC_ADD(&s->be->be_counters.failed_resp, 1);
                        if (objt_server(s->target)) {
                                _HA_ATOMIC_ADD(&__objt_server(s->target)->counters.failed_resp, 1);
@@ -1591,15 +1591,15 @@ int htx_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
 
                /* 4: close from server, capture the response if the server has started to respond */
                else if (rep->flags & CF_SHUTR) {
-                       if (txn->flags & TX_NOT_FIRST)
-                               goto abort_keep_alive;
-
                        if ((si_b->flags & SI_FL_L7_RETRY) &&
                            (s->be->retry_type & PR_RE_DISCONNECTED)) {
                                if (co_data(rep) || do_l7_retry(s, si_b) == 0)
                                        return 0;
                        }
 
+                       if (txn->flags & TX_NOT_FIRST)
+                               goto abort_keep_alive;
+
                        _HA_ATOMIC_ADD(&s->be->be_counters.failed_resp, 1);
                        if (objt_server(s->target)) {
                                _HA_ATOMIC_ADD(&__objt_server(s->target)->counters.failed_resp, 1);