From: Willy Tarreau Date: Wed, 23 Jan 2019 19:43:53 +0000 (+0100) Subject: BUG/MINOR: mux-h1: avoid copying output over itself in zero-copy X-Git-Tag: v2.0-dev1~174 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b57af617c06347af2284ac7949a7ddd7e52b4e41;p=thirdparty%2Fhaproxy.git BUG/MINOR: mux-h1: avoid copying output over itself in zero-copy It's almost funny but one side effect of the latest zero-copy changes made to mux-h1 resulted in the temporary buffer being copied over itself at the exact same location. This has no impact except slowing down operations and irritating valgrind. The cause is an incorrect pointer check after the alignment optimizations were made. This needs to be backported to 1.9. Reported-by: Tim Duesterhus --- diff --git a/src/mux_h1.c b/src/mux_h1.c index a5d60c3c4e..d928cef9b4 100644 --- a/src/mux_h1.c +++ b/src/mux_h1.c @@ -1658,7 +1658,7 @@ static size_t h1_process_output(struct h1c *h1c, struct buffer *buf, size_t coun /* when the output buffer is empty, tmp shares the same area so that we * only have to update pointers and lengths. */ - if (tmp->area == h1c->obuf.area) + if (tmp->area == h1c->obuf.area + h1c->obuf.head) h1c->obuf.data = tmp->data; else b_putblk(&h1c->obuf, tmp->area, tmp->data);