]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: htx: make htx_from_buf() adjust the size only on new buffers
authorWilly Tarreau <w@1wt.eu>
Wed, 5 Dec 2018 08:47:34 +0000 (09:47 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 5 Dec 2018 09:57:42 +0000 (10:57 +0100)
This one is used a lot during transfers, let's avoid resetting its
size when there are already data in the buffer since it implies the
size is correct.

include/proto/htx.h

index e59bb4f48e2ea0809fb5873944ce33db5f9f465a..b6f1042f45b3bca0e3857e1b99ef7d1164c03dec 100644 (file)
@@ -532,9 +532,10 @@ static inline struct htx *htx_from_buf(struct buffer *buf)
         if (b_is_null(buf))
                 return &htx_empty;
         htx = (struct htx *)(buf->area);
-        htx->size = buf->size - sizeof(*htx);
-        if (!b_data(buf))
+        if (!b_data(buf)) {
+               htx->size = buf->size - sizeof(*htx);
                 htx_reset(htx);
+       }
        return htx;
 }