From: Christopher Faulet Date: Tue, 14 May 2019 20:14:03 +0000 (+0200) Subject: MINOR: channel/htx: Call channel_htx_recv_max() from channel_recv_max() X-Git-Tag: v2.0-dev5~48 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=aad458587dda20f42476463fc2b82753f6546336;p=thirdparty%2Fhaproxy.git MINOR: channel/htx: Call channel_htx_recv_max() from channel_recv_max() When channel_recv_max() is called for an HTX stream, we fall back on the HTX version. This function is called from si_cs_recv(). This will let us pass the max amount of bytes to read to HTX multiplexers. --- diff --git a/include/proto/channel.h b/include/proto/channel.h index b2cd5c3745..b53e177935 100644 --- a/include/proto/channel.h +++ b/include/proto/channel.h @@ -38,6 +38,7 @@ #include #include +#include #include /* perform minimal intializations, report 0 in case of error, 1 if OK. */ @@ -778,27 +779,30 @@ static inline int channel_htx_full(const struct channel *c, const struct htx *ht } -/* Returns the amount of space available at the input of the buffer, taking the - * reserved space into account if ->to_forward indicates that an end of transfer - * is close to happen. The test is optimized to avoid as many operations as - * possible for the fast case. - */ -static inline int channel_recv_max(const struct channel *chn) +/* HTX version of channel_recv_max(). */ +static inline int channel_htx_recv_max(const struct channel *chn, const struct htx *htx) { int ret; - ret = channel_recv_limit(chn) - b_data(&chn->buf); + ret = channel_htx_recv_limit(chn, htx) - htx_used_space(htx); if (ret < 0) ret = 0; return ret; } -/* HTX version of channel_recv_max(). */ -static inline int channel_htx_recv_max(const struct channel *chn, const struct htx *htx) +/* Returns the amount of space available at the input of the buffer, taking the + * reserved space into account if ->to_forward indicates that an end of transfer + * is close to happen. The test is optimized to avoid as many operations as + * possible for the fast case. + */ +static inline int channel_recv_max(const struct channel *chn) { int ret; - ret = channel_htx_recv_limit(chn, htx) - htx->data; + if (IS_HTX_STRM(chn_strm(chn))) + return channel_htx_recv_max(chn, htxbuf(&chn->buf)); + + ret = channel_recv_limit(chn) - b_data(&chn->buf); if (ret < 0) ret = 0; return ret;