mirror of
https://github.com/haproxy/haproxy.git
synced 2026-05-28 04:12:17 -04:00
MINOR: buffer: add br_single() to check if a buffer ring has more than one buf
It's cheaper and cleaner than using br_count()==1 given that it just compares two indexes, and that a ring having a single buffer is in a special case where it is between empty and used up-to-1. In other words it's not congested.
This commit is contained in:
parent
e5a26eb2de
commit
9824f8c890
1 changed files with 8 additions and 0 deletions
|
|
@ -1027,6 +1027,14 @@ static inline unsigned int br_count(const struct buffer *r)
|
|||
return r->data + r->size - r->head;
|
||||
}
|
||||
|
||||
/* Returns true if a single buffer is assigned */
|
||||
static inline unsigned int br_single(const struct buffer *r)
|
||||
{
|
||||
BUG_ON_HOT(r->area != BUF_RING.area);
|
||||
|
||||
return r->data == r->head;
|
||||
}
|
||||
|
||||
/* Returns the index of the ring's head buffer */
|
||||
static inline unsigned int br_head_idx(const struct buffer *r)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue