mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-02-19 12:16:59 +00:00
MINOR: channel: add channel_in_transit()
This function returns the amount of bytes in transit in a channel's buffer, which is the amount of outgoing data plus the amount of incoming data bound to the forward limit.
This commit is contained in:
parent
bb3f994f1a
commit
1a4484dec8
@ -117,6 +117,27 @@ static inline int channel_reserved(const struct channel *chn)
|
||||
return rem >= 0;
|
||||
}
|
||||
|
||||
/* Returns the amount of bytes from the channel that are already scheduled for
|
||||
* leaving (buf->o) or that are still part of the input and expected to be sent
|
||||
* soon as covered by to_forward. This is useful to know by how much we can
|
||||
* shrink the rewrite reserve during forwards.
|
||||
*/
|
||||
static inline int channel_in_transit(const struct channel *chn)
|
||||
{
|
||||
int ret;
|
||||
|
||||
/* below, this is min(i, to_forward) optimized for the fast case */
|
||||
if (chn->to_forward >= chn->buf->i ||
|
||||
(CHN_INFINITE_FORWARD < MAX_RANGE(typeof(chn->buf->i)) &&
|
||||
chn->to_forward == CHN_INFINITE_FORWARD))
|
||||
ret = chn->buf->i;
|
||||
else
|
||||
ret = chn->to_forward;
|
||||
|
||||
ret += chn->buf->o;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Returns non-zero if the buffer input is considered full. This is used to
|
||||
* decide when to stop reading into a buffer when we want to ensure that we
|
||||
* leave the reserve untouched after all pending outgoing data are forwarded.
|
||||
|
Loading…
Reference in New Issue
Block a user