]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: h1: Realign the ibuf before calling rcv_buf if needed.
authorOlivier Houchard <ohouchard@haproxy.com>
Tue, 4 Dec 2018 17:16:45 +0000 (18:16 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 4 Dec 2018 17:42:33 +0000 (18:42 +0100)
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().

src/mux_h1.c

index b0d5567000ac5426bb7f9d9c00916a1096f7850c..1c980dca6d712ab6e168c99167522ce4d23bfa1f 100644 (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;