mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-23 23:01:24 +02:00
MEDIUM: channel: make bi_avail() use channel_in_transit()
This ensures that we rely on a sane computation for the buffer size.
This commit is contained in:
parent
fe57834955
commit
27bb0e14a8
@ -311,28 +311,12 @@ static inline int buffer_max_len(const struct channel *chn)
|
|||||||
*/
|
*/
|
||||||
static inline int bi_avail(const struct channel *chn)
|
static inline int bi_avail(const struct channel *chn)
|
||||||
{
|
{
|
||||||
int rem = chn->buf->size;
|
int ret;
|
||||||
int rem2;
|
|
||||||
|
|
||||||
rem -= chn->buf->o;
|
ret = buffer_max_len(chn) - chn->buf->i - chn->buf->o;
|
||||||
rem -= chn->buf->i;
|
if (ret < 0)
|
||||||
if (!rem)
|
ret = 0;
|
||||||
return rem; /* buffer already full */
|
return ret;
|
||||||
|
|
||||||
if (chn->to_forward >= chn->buf->i ||
|
|
||||||
(CHN_INFINITE_FORWARD < MAX_RANGE(typeof(chn->buf->i)) && // just there to ensure gcc
|
|
||||||
chn->to_forward == CHN_INFINITE_FORWARD)) // avoids the useless second
|
|
||||||
return rem; // test whenever possible
|
|
||||||
|
|
||||||
rem2 = rem - global.tune.maxrewrite;
|
|
||||||
rem2 += chn->buf->o;
|
|
||||||
rem2 += chn->to_forward;
|
|
||||||
|
|
||||||
if (rem > rem2)
|
|
||||||
rem = rem2;
|
|
||||||
if (rem > 0)
|
|
||||||
return rem;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Cut the "tail" of the channel's buffer, which means strip it to the length
|
/* Cut the "tail" of the channel's buffer, which means strip it to the length
|
||||||
|
Loading…
x
Reference in New Issue
Block a user