/***** 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)
{
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
* 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.
*/
/* 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)) {
}
/* 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;
/* 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 */
* - 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