From: Olivier Houchard Date: Tue, 4 Dec 2018 17:16:45 +0000 (+0100) Subject: MEDIUM: h1: Realign the ibuf before calling rcv_buf if needed. X-Git-Tag: v1.9-dev10~48 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=29a22bc0a7fcc25e02b1fd173c8f0095d653d501;p=thirdparty%2Fhaproxy.git MEDIUM: h1: Realign the ibuf before calling rcv_buf if needed. If the ibuf only contains a small amount of data, realign it before calling rcv_buf(), as it's probably going to be cheaper to do so than to do 2 calls to recv(). --- diff --git a/src/mux_h1.c b/src/mux_h1.c index b0d5567000..1c980dca6d 100644 --- a/src/mux_h1.c +++ b/src/mux_h1.c @@ -1484,6 +1484,13 @@ static int h1_recv(struct h1c *h1c) goto end; } + /* + * If we only have a small amount of data, realign it, + * 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); + max = b_room(&h1c->ibuf); if (max) { h1c->flags &= ~H1C_F_IN_FULL;