From: Willy Tarreau Date: Wed, 14 Jan 2015 13:07:13 +0000 (+0100) Subject: MEDIUM: channel: make buffer_reserved() use channel_in_transit() X-Git-Tag: v1.6-dev1~196 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fe5783495546da274c0270f0f59e3f84de3bf790;p=thirdparty%2Fhaproxy.git MEDIUM: channel: make buffer_reserved() use channel_in_transit() This ensures that we rely on a sane computation for the buffer size. --- diff --git a/include/proto/channel.h b/include/proto/channel.h index 1648a6dad7..dccb987218 100644 --- a/include/proto/channel.h +++ b/include/proto/channel.h @@ -287,16 +287,11 @@ static inline void channel_dont_read(struct channel *chn) */ static inline int buffer_reserved(const struct channel *chn) { - unsigned int reserved = global.tune.maxrewrite; + int reserved; - if (chn->to_forward == CHN_INFINITE_FORWARD || - chn->to_forward >= reserved || - chn->buf->o >= reserved || - chn->to_forward + chn->buf->o >= reserved) + reserved = global.tune.maxrewrite - channel_in_transit(chn); + if (reserved < 0) reserved = 0; - else - reserved -= chn->to_forward + chn->buf->o; - return reserved; }