]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: htx: Add a function to know if the free space wraps
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 21 Sep 2021 13:45:05 +0000 (15:45 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 23 Sep 2021 14:19:36 +0000 (16:19 +0200)
the htx_space_wraps() function may now be used to know if the free space of
an HTX message wraps. It does the same as b_space_wraps().

include/haproxy/htx.h

index 0faf29646765b92475ed5c6ae05c947268c989a8..c7ae3089137894d7c36c75a01338c2a52d62cb21 100644 (file)
@@ -606,6 +606,17 @@ static inline uint32_t htx_free_data_space(const struct htx *htx)
        return (free - sizeof(struct htx_blk));
 }
 
+/* Returns non-zero only if the HTX message free space wraps */
+static inline int htx_space_wraps(const struct htx *htx)
+{
+       uint32_t headroom, tailroom;
+
+       headroom = (htx->end_addr - htx->head_addr);
+       tailroom = (htx_pos_to_addr(htx, htx->tail) - htx->tail_addr);
+
+       return (headroom && tailroom);
+}
+
 /* Returns the maximum size for a block, not exceeding <max> bytes. <max> may be
  * set to -1 to have no limit.
  */