]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: htx: Use a macro for overhead induced by HTX
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 17 Nov 2023 09:52:36 +0000 (10:52 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 17 Nov 2023 11:13:00 +0000 (12:13 +0100)
The overhead induced by the HTX format was set to the HTX structure itself
and two HTX blocks. It was set this way to optimize zero-copy during
transfers. This value may (and will) be used at different places. Thus we
now use a macro, called HTX_BUF_OVERHEAD.

include/haproxy/htx-t.h
include/haproxy/htx.h

index 687e403c7bc765cb53fd7f0df091f31c84e8a74c..2ea6bc8b2bed7e8d9723b0727e90ef7932e13761 100644 (file)
@@ -164,6 +164,12 @@ static forceinline char *hsl_show_flags(char *buf, size_t len, const char *delim
 #undef _
 }
 
+/* Overhead induced by HTX on buffers during transfers. In addition to the size
+ * of the HTX structure itself, and meta data for one block, another block is
+ * accounted to favored zero-copy xfer.
+ */
+#define HTX_BUF_OVERHEAD     (sizeof(struct htx) + 2 * sizeof(struct htx_blk))
+
 /* HTX flags.
  * Please also update the htx_show_flags() function below in case of changes.
  */
index 59e885a670d75ad0c8355844696c175cfff2a000..c991c81e5c4ea3e9b391490b87c2e380909b5838 100644 (file)
@@ -673,10 +673,10 @@ static inline size_t buf_room_for_htx_data(const struct buffer *buf)
        size_t room;
 
        room = b_room(buf);
-       if (room <= sizeof(struct htx) + 2 * sizeof(struct htx_blk))
+       if (room <= HTX_BUF_OVERHEAD)
                room = 0;
        else
-               room -= sizeof(struct htx) + 2 * sizeof(struct htx_blk);
+               room -= HTX_BUF_OVERHEAD;
 
        return room;
 }