]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: http-ana: Perform L7 retries because of status codes in response analyser
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 26 May 2021 11:14:39 +0000 (13:14 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 26 May 2021 11:56:06 +0000 (13:56 +0200)
L7 retries because of status codes are now performed in the response
analyser. This way, it is no longer required to handle L7 retries in
si_cs_recv(). It is also useless to set CF_READ_ERROR on the response
channel to be able to trigger such retries.

In addition, if no L7 retries are performed when the response is received,
the L7 buffer is immediately released. Before in this case, it was only
released with the stream.

src/http_ana.c
src/stream_interface.c

index a52b0f24a746cb9ab73d43b5d533a1b5575e60f3..a045e53fe04fa322cdd9299dd2b963f2e29a9c1e 100644 (file)
@@ -1542,10 +1542,23 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
         * response which at least looks like HTTP. We have an indicator
         * of each header's length, so we can parse them quickly.
         */
-       msg->msg_state = HTTP_MSG_BODY;
        BUG_ON(htx_get_first_type(htx) != HTX_BLK_RES_SL);
        sl = http_get_stline(htx);
 
+       /* Perform a L7 retry because of the status code */
+       if ((si_b->flags & SI_FL_L7_RETRY) &&
+           l7_status_match(s->be, sl->info.res.status) &&
+           do_l7_retry(s, si_b) == 0) {
+               DBG_TRACE_DEVEL("leaving on L7 retry", STRM_EV_STRM_ANA|STRM_EV_HTTP_ANA, s, txn);
+               return 0;
+       }
+
+       /* Now, L7 buffer is useless, it can be released */
+       b_free(&s->si[1].l7_buffer);
+
+       msg->msg_state = HTTP_MSG_BODY;
+
+
        /* 0: we might have to print this header in debug mode */
        if (unlikely((global.mode & MODE_DEBUG) &&
                     (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE)))) {
index 6d26919d8d329144af26e474fdc076fcdf583f8b..cd01840e25731fca6bef71c1c945729298a67dc4 100644 (file)
@@ -1367,28 +1367,6 @@ int si_cs_recv(struct conn_stream *cs)
                        break;
                }
 
-               /* L7 retries enabled and maximum connection retries not reached */
-               if ((si->flags & SI_FL_L7_RETRY) && si->conn_retries) {
-                       struct htx *htx;
-                       struct htx_sl *sl;
-
-                       htx = htxbuf(&ic->buf);
-                       if (htx) {
-                               sl = http_get_stline(htx);
-                               if (sl && l7_status_match(si_strm(si)->be,
-                                   sl->info.res.status)) {
-                                       /* If we got a status for which we would
-                                        * like to retry the request, empty
-                                        * the buffer and pretend there's an
-                                        * error on the channel.
-                                        */
-                                       ic->flags |= CF_READ_ERROR;
-                                       htx_reset(htx);
-                                       return 1;
-                               }
-                       }
-                       si->flags &= ~SI_FL_L7_RETRY;
-               }
                cur_read += ret;
 
                /* if we're allowed to directly forward data, we must update ->o */