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().
This commit is contained in:
Olivier Houchard 2018-12-04 18:16:45 +01:00 committed by Willy Tarreau
parent cf42d5afa0
commit 29a22bc0a7

View File

@ -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;