MINOR: htx: Use a macro for overhead induced by HTX
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.
(cherry picked from commit 7393bf7e424d4cd2e0927bf4dc95eb799ec67dd4)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit bffaf79459dae517a212f3f84269251d689491fd)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit bfb0e2a53611433b17400c1d2b318334a57255b9)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit cdd881f788ed404c45ec89f1a01dda0b4cccbbd3)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
diff --git a/include/haproxy/htx-t.h b/include/haproxy/htx-t.h
index 404a66e..ac193d4 100644
--- a/include/haproxy/htx-t.h
+++ b/include/haproxy/htx-t.h
@@ -138,7 +138,15 @@
#define HTX_SL_F_NORMALIZED_URI 0x00000800 /* The received URI is normalized (an implicit absolute-uri form) */
#define HTX_SL_F_CONN_UPG 0x00001000 /* The message contains "connection: upgrade" header */
-/* HTX flags */
+/* 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.
+ */
#define HTX_FL_NONE 0x00000000
#define HTX_FL_PARSING_ERROR 0x00000001 /* Set when a parsing error occurred */
#define HTX_FL_PROCESSING_ERROR 0x00000002 /* Set when a processing error occurred */
diff --git a/include/haproxy/htx.h b/include/haproxy/htx.h
index ca24213..7f5ff26 100644
--- a/include/haproxy/htx.h
+++ b/include/haproxy/htx.h
@@ -658,10 +658,10 @@
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;
}