From 8ae4235f9454564dbb9f31cc827fccda5049e865 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Wed, 5 Dec 2018 09:47:34 +0100 Subject: [PATCH] MINOR: htx: make htx_from_buf() adjust the size only on new buffers 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 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/proto/htx.h b/include/proto/htx.h index e59bb4f48..b6f1042f4 100644 --- a/include/proto/htx.h +++ b/include/proto/htx.h @@ -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; }