DEBUG: buf: replace some sensitive BUG_ON() with BUG_ON_HOT()
The buffer ring management functions br_* were all stuffed with BUG_ON()
statements that never triggered and that are on some fast paths (e.g. in
mux_h2). Let's turn them to BUG_ON_HOT() instead.
diff --git a/include/haproxy/buf.h b/include/haproxy/buf.h
index de359f5..fe6f42e 100644
--- a/include/haproxy/buf.h
+++ b/include/haproxy/buf.h
@@ -949,7 +949,7 @@
/* Returns number of elements in the ring, root included */
static inline unsigned int br_size(const struct buffer *r)
{
- BUG_ON(r->area != BUF_RING.area);
+ BUG_ON_HOT(r->area != BUF_RING.area);
return r->size;
}
@@ -957,7 +957,7 @@
/* Returns true if no more buffers may be added */
static inline unsigned int br_full(const struct buffer *r)
{
- BUG_ON(r->area != BUF_RING.area);
+ BUG_ON_HOT(r->area != BUF_RING.area);
return r->data + 1 == r->head || r->data + 1 == r->head - 1 + r->size;
}
@@ -965,7 +965,7 @@
/* Returns the index of the ring's head buffer */
static inline unsigned int br_head_idx(const struct buffer *r)
{
- BUG_ON(r->area != BUF_RING.area);
+ BUG_ON_HOT(r->area != BUF_RING.area);
return r->head;
}
@@ -973,7 +973,7 @@
/* Returns the index of the ring's tail buffer */
static inline unsigned int br_tail_idx(const struct buffer *r)
{
- BUG_ON(r->area != BUF_RING.area);
+ BUG_ON_HOT(r->area != BUF_RING.area);
return r->data;
}
@@ -981,7 +981,7 @@
/* Returns a pointer to the ring's head buffer */
static inline struct buffer *br_head(struct buffer *r)
{
- BUG_ON(r->area != BUF_RING.area);
+ BUG_ON_HOT(r->area != BUF_RING.area);
return r + br_head_idx(r);
}
@@ -989,7 +989,7 @@
/* Returns a pointer to the ring's tail buffer */
static inline struct buffer *br_tail(struct buffer *r)
{
- BUG_ON(r->area != BUF_RING.area);
+ BUG_ON_HOT(r->area != BUF_RING.area);
return r + br_tail_idx(r);
}
@@ -997,7 +997,7 @@
/* Returns the amount of data of the ring's HEAD buffer */
static inline unsigned int br_data(const struct buffer *r)
{
- BUG_ON(r->area != BUF_RING.area);
+ BUG_ON_HOT(r->area != BUF_RING.area);
return b_data(r + br_head_idx(r));
}
@@ -1005,7 +1005,7 @@
/* Returns non-zero if the ring is non-full or its tail has some room */
static inline unsigned int br_has_room(const struct buffer *r)
{
- BUG_ON(r->area != BUF_RING.area);
+ BUG_ON_HOT(r->area != BUF_RING.area);
if (!br_full(r))
return 1;
@@ -1021,7 +1021,7 @@
{
struct buffer *b;
- BUG_ON(r->area != BUF_RING.area);
+ BUG_ON_HOT(r->area != BUF_RING.area);
b = br_tail(r);
if (!b_size(b))
@@ -1050,7 +1050,7 @@
{
struct buffer *b;
- BUG_ON(r->area != BUF_RING.area);
+ BUG_ON_HOT(r->area != BUF_RING.area);
b = br_head(r);
if (r->head != r->data) {
@@ -1068,7 +1068,7 @@
*/
static inline struct buffer *br_del_head(struct buffer *r)
{
- BUG_ON(r->area != BUF_RING.area);
+ BUG_ON_HOT(r->area != BUF_RING.area);
if (r->head != r->data) {
r->head++;