From 00d7cde5519ba8601a3b3b2137cc43f1cf79b84e Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Thu, 4 Feb 2021 11:01:51 +0100 Subject: [PATCH] MINOR: muxes/h1-htx: Realign input buffer using b_slow_realign_ofs() 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 | 4 ++-- src/mux_fcgi.c | 4 ++-- src/mux_h1.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/h1_htx.c b/src/h1_htx.c index ec240a303..b4c49c781 100644 --- a/src/h1_htx.c +++ b/src/h1_htx.c @@ -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), diff --git a/src/mux_fcgi.c b/src/mux_fcgi.c index bc9d0232c..6fd76535f 100644 --- a/src/mux_fcgi.c +++ b/src/mux_fcgi.c @@ -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); diff --git a/src/mux_h1.c b/src/mux_h1.c index b90e11c9e..31f64c3f8 100644 --- a/src/mux_h1.c +++ b/src/mux_h1.c @@ -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 ||