]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: htx: Optimize htx_drain() when all data are drained
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 23 May 2019 09:11:52 +0000 (11:11 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 28 May 2019 05:42:33 +0000 (07:42 +0200)
Instead of looping on the HTX message to drain all data, the message is now
reset..

src/htx.c

index dbf8dea3797498d7edbadd93b8539a06994f93e1..60bfc049b2615c790854a0f796199c96d879634b 100644 (file)
--- a/src/htx.c
+++ b/src/htx.c
@@ -309,6 +309,12 @@ struct htx_ret htx_drain(struct htx *htx, uint32_t count)
        struct htx_blk *blk;
        struct htx_ret htxret = { .blk = NULL, .ret = 0 };
 
+       if (count == htx->data) {
+               htx_reset(htx);
+               htxret.ret = count;
+               return htxret;
+       }
+
        blk = htx_get_head_blk(htx);
        while (count && blk) {
                uint32_t sz = htx_get_blksz(blk);