mirror of
https://github.com/haproxy/haproxy.git
synced 2026-03-28 05:14:56 -04:00
MINOR: buffer: add br_count() to return the number of allocated bufs
We have no way to know how many buffers are currently allocated in a buffer ring. Let's add br_count() for this.
This commit is contained in:
parent
3fb2c6d5b4
commit
e5a26eb2de
1 changed files with 11 additions and 0 deletions
|
|
@ -1016,6 +1016,17 @@ static inline unsigned int br_full(const struct buffer *r)
|
|||
return r->data + 1 == r->head || r->data + 1 == r->head - 1 + r->size;
|
||||
}
|
||||
|
||||
/* Returns the number of buffers present */
|
||||
static inline unsigned int br_count(const struct buffer *r)
|
||||
{
|
||||
BUG_ON_HOT(r->area != BUF_RING.area);
|
||||
|
||||
if (r->data >= r->head)
|
||||
return r->data - r->head + 1;
|
||||
else
|
||||
return r->data + r->size - 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