]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: muxes/h1-htx: Realign input buffer using b_slow_realign_ofs()
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 4 Feb 2021 10:01:51 +0000 (11:01 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 25 May 2021 08:41:50 +0000 (10:41 +0200)
Input buffers have never output data. So, use b_slow_realign_ofs() function
instead of b_slow_realign(). It is a slighly simpler function. And in the H1
mux, it allows a realign by setting the input buffer head to permit
zero-copies.

src/h1_htx.c
src/mux_fcgi.c
src/mux_h1.c

index ec240a303babc12f31858d0dd85ac04f6ed031f6..b4c49c781febb650baccaf1bf48b6f3bbee3da27 100644 (file)
@@ -319,7 +319,7 @@ size_t h1_parse_msg_hdrs(struct h1m *h1m, union h1_sl *h1sl, struct htx *dsthtx,
 
        /* Realing input buffer if necessary */
        if (b_head(srcbuf) + b_data(srcbuf) > b_wrap(srcbuf))
-               b_slow_realign(srcbuf, trash.area, 0);
+               b_slow_realign_ofs(srcbuf, trash.area, 0);
 
        if (!h1sl) {
                /* If there no start-line, be sure to only parse the headers */
@@ -857,7 +857,7 @@ size_t h1_parse_msg_tlrs(struct h1m *h1m, struct htx *dsthtx,
 
        /* Realing input buffer if necessary */
        if (b_peek(srcbuf, ofs) > b_tail(srcbuf))
-               b_slow_realign(srcbuf, trash.area, 0);
+               b_slow_realign_ofs(srcbuf, trash.area, 0);
 
        tlr_h1m.flags = (H1_MF_NO_PHDR|H1_MF_HDRS_ONLY);
        ret = h1_headers_to_hdr_list(b_peek(srcbuf, ofs), b_tail(srcbuf),
index bc9d0232c5fc972d40b45106dea5acc0f4059509..6fd76535f9c100119b9c7dccc53e3177ffa4e673 100644 (file)
@@ -1623,7 +1623,7 @@ static int fcgi_conn_handle_values_result(struct fcgi_conn *fconn)
                 * at this stage because it should be the first record received
                 * from the FCGI application.
                 */
-               b_slow_realign(dbuf, trash.area, 0);
+               b_slow_realign_ofs(dbuf, trash.area, 0);
        }
 
        inbuf = b_make(b_head(dbuf), b_data(dbuf), 0, fconn->drl);
@@ -2488,7 +2488,7 @@ static int fcgi_strm_handle_end_request(struct fcgi_conn *fconn, struct fcgi_str
                 * at this stage because it should be the first record received
                 * from the FCGI application.
                 */
-               b_slow_realign(dbuf, trash.area, 0);
+               b_slow_realign_ofs(dbuf, trash.area, 0);
        }
 
        inbuf = b_make(b_head(dbuf), b_data(dbuf), 0, fconn->drl);
index b90e11c9e440f89487fc58c09e6ffeaa936fb864..31f64c3f8f048ca1b0d1390d5914a437dcb49791 100644 (file)
@@ -2519,7 +2519,7 @@ static int h1_recv(struct h1c *h1c)
         * it's probably cheaper than doing 2 recv() calls.
         */
        if (b_data(&h1c->ibuf) > 0 && b_data(&h1c->ibuf) < 128)
-               b_slow_realign(&h1c->ibuf, trash.area, 0);
+               b_slow_realign_ofs(&h1c->ibuf, trash.area, sizeof(struct htx));
 
        /* avoid useless reads after first responses */
        if (!h1c->h1s ||