mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-05 22:56:57 +02:00
MINOR: dynbuf: provide a b_dequeue() function to detach a bw from the queue
Now that we need to keep the bitmap in sync with the list heads, we don't want tasks to leave just doing a LIST_DEL_INIT() without updating the map. Let's provide a b_dequeue() function for that purpose. The function detects when it's going to remove the last element and figures the queue number based on the pointer since it points to the root. It's not used yet.
This commit is contained in:
parent
53461e4d94
commit
f70bd5fad1
@ -168,6 +168,29 @@ static inline int b_queue(enum dynbuf_crit crit, struct buffer_wait *bw, void *c
|
||||
return b_requeue(crit, bw);
|
||||
}
|
||||
|
||||
/* Dequeues bw element <bw> from its list and updates the bufq_map if if was
|
||||
* the last element. All users of buffer_wait should use this to dequeue (e.g.
|
||||
* when killing a pending request on timeout) so as to make sure that we keep
|
||||
* consistency between the list heads and the bitmap.
|
||||
*/
|
||||
static inline void b_dequeue(struct buffer_wait *bw)
|
||||
{
|
||||
uint q;
|
||||
|
||||
if (likely(!LIST_INLIST(&bw->list)))
|
||||
return;
|
||||
|
||||
/* trick: detect if we're the last one and pointing to a root, so we
|
||||
* can figure the queue number since the root belongs to an array.
|
||||
*/
|
||||
if (LIST_ATMOST1(&bw->list)) {
|
||||
/* OK then which root? */
|
||||
q = bw->list.n - &th_ctx->buffer_wq[0];
|
||||
BUG_ON_HOT(q >= DYNBUF_NBQ);
|
||||
th_ctx->bufq_map &= ~(1 << q);
|
||||
}
|
||||
LIST_DEL_INIT(&bw->list);
|
||||
}
|
||||
|
||||
#endif /* _HAPROXY_DYNBUF_H */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user