MINOR: buffer: replace buffer_full() with channel_full()
It's only used by channels since we need to know the amount of output
data.
diff --git a/include/common/buffer.h b/include/common/buffer.h
index 976ea02..c0fdab4 100644
--- a/include/common/buffer.h
+++ b/include/common/buffer.h
@@ -61,23 +61,6 @@
/***** FIXME: OLD API BELOW *****/
-/* Returns non-zero if the buffer's INPUT is considered full, which means that
- * it holds at least as much INPUT data as (size - reserve). This also means
- * that data that are scheduled for output are considered as potential free
- * space, and that the reserved space is always considered as not usable. This
- * information alone cannot be used as a general purpose free space indicator.
- * However it accurately indicates that too many data were fed in the buffer
- * for an analyzer for instance. See the channel_may_recv() function for a more
- * generic function taking everything into account.
- */
-static inline int buffer_full(const struct buffer *b, unsigned int reserve)
-{
- if (b == &buf_empty)
- return 0;
-
- return (b->i + reserve >= b->size);
-}
-
/* Normalizes a pointer after a subtract */
static inline char *buffer_wrap_sub(const struct buffer *buf, char *ptr)
{
diff --git a/include/proto/channel.h b/include/proto/channel.h
index 850f900..18597e4 100644
--- a/include/proto/channel.h
+++ b/include/proto/channel.h
@@ -637,6 +637,24 @@
return chn->buf->size - reserve;
}
+/* Returns non-zero if the channel's INPUT buffer's is considered full, which
+ * means that it holds at least as much INPUT data as (size - reserve). This
+ * also means that data that are scheduled for output are considered as potential
+ * free space, and that the reserved space is always considered as not usable.
+ * This information alone cannot be used as a general purpose free space indicator.
+ * However it accurately indicates that too many data were fed in the buffer
+ * for an analyzer for instance. See the channel_may_recv() function for a more
+ * generic function taking everything into account.
+ */
+static inline int channel_full(const struct channel *c, unsigned int reserve)
+{
+ if (c->buf == &buf_empty)
+ return 0;
+
+ return (b_data(c->buf) - co_data(c) + reserve >= c_size(c));
+}
+
+
/* 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
diff --git a/src/proto_http.c b/src/proto_http.c
index 3d83e1b..7f90373 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -1717,7 +1717,7 @@
* later, so the stream will never terminate. We
* must terminate it now.
*/
- if (unlikely(buffer_full(req->buf, global.tune.maxrewrite))) {
+ if (unlikely(channel_full(req, global.tune.maxrewrite))) {
/* FIXME: check if URI is set and return Status
* 414 Request URI too long instead.
*/
@@ -4177,7 +4177,7 @@
/* we get here if we need to wait for more data. If the buffer is full,
* we have the maximum we can expect.
*/
- if (buffer_full(req->buf, global.tune.maxrewrite))
+ if (channel_full(req, global.tune.maxrewrite))
goto http_end;
if ((req->flags & CF_READ_TIMEOUT) || tick_is_expired(req->analyse_exp, now_ms)) {
@@ -5211,7 +5211,7 @@
}
/* too large response does not fit in buffer. */
- else if (buffer_full(rep->buf, global.tune.maxrewrite)) {
+ else if (channel_full(rep, global.tune.maxrewrite)) {
if (msg->err_pos < 0)
msg->err_pos = rep->buf->i;
goto hdr_response_bad;
@@ -9530,7 +9530,7 @@
/* Still no valid request ? */
if (unlikely(msg->msg_state < HTTP_MSG_BODY)) {
if ((msg->msg_state == HTTP_MSG_ERROR) ||
- buffer_full(s->req.buf, global.tune.maxrewrite)) {
+ channel_full(&s->req, global.tune.maxrewrite)) {
return 0;
}
/* wait for final state */
diff --git a/src/tcp_rules.c b/src/tcp_rules.c
index deb34ac..e21c5b7 100644
--- a/src/tcp_rules.c
+++ b/src/tcp_rules.c
@@ -122,7 +122,7 @@
* - if one rule returns KO, then return KO
*/
- if ((req->flags & CF_SHUTR) || buffer_full(req->buf, global.tune.maxrewrite) ||
+ if ((req->flags & CF_SHUTR) || channel_full(req, global.tune.maxrewrite) ||
!s->be->tcp_req.inspect_delay || tick_is_expired(req->analyse_exp, now_ms))
partial = SMP_OPT_FINAL;
else