]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: http-ana: Do nothing in wait-for-request analyzer if not htx
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 21 Jan 2021 16:32:58 +0000 (17:32 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 28 Jan 2021 15:27:48 +0000 (16:27 +0100)
If http_wait_for_request() analyzer is called with a non-htx stream, nothing
is performed and we return immediatly. For now, it is totally unexpected.
But it will be true during TCP to H1 upgrades, once fixed. Indeed, there
will be a transition period during these upgrades. First the mux will be
upgraded and the not the stream, and finally the stream will be upgraded by
the mux once ready. In the meantime, the stream will still be in raw
mode. Nothing will be performed in wait-for-request analyzer because it will
be the mux responsibility to handle errors.

This patch is required to fix the TCP to H1 upgrades.

src/http_ana.c

index dd6ac4167b30800fcd0cc5b1caedb40f0e6a3b6e..7816ad5630840fd5315eddbc48e6cb9510cd097d 100644 (file)
@@ -92,9 +92,20 @@ int http_wait_for_request(struct stream *s, struct channel *req, int an_bit)
 
        DBG_TRACE_ENTER(STRM_EV_STRM_ANA|STRM_EV_HTTP_ANA, s, txn, msg);
 
-       htx = htxbuf(&req->buf);
+       if (unlikely(!IS_HTX_STRM(s))) {
+               /* It is only possible when a TCP stream is upgrade to HTTP.
+                * There is a transition period during which there is no
+                * data. The stream is still in raw mode and SF_IGNORE flag is
+                * still set. When this happens, the new mux is responsible to
+                * handle all errors. Thus we may leave immediatly.
+                */
+               BUG_ON(!(s->flags & SF_IGNORE) || !c_empty(&s->req));
+
+               DBG_TRACE_LEAVE(STRM_EV_STRM_ANA, s);
+               return 0;
+       }
 
-       BUG_ON(htx_is_empty(htx) || htx->first == -1);
+       htx = htxbuf(&req->buf);
 
        /* Parsing errors are caught here */
        if (htx->flags & (HTX_FL_PARSING_ERROR|HTX_FL_PROCESSING_ERROR)) {