From: Willy Tarreau Date: Tue, 13 Jan 2015 13:39:16 +0000 (+0100) Subject: CLEANUP: channel: rename channel_reserved -> channel_is_rewritable X-Git-Tag: v1.6-dev1~193 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ba0902ede4f9188714c8aa15791ca85847162960;p=thirdparty%2Fhaproxy.git CLEANUP: channel: rename channel_reserved -> channel_is_rewritable channel_reserved is confusingly named. It is used to know whether or not the rewrite area is left intact for situations where we want to ensure we can use it before proceeding. Let's rename it to fix this confusion. --- diff --git a/include/proto/channel.h b/include/proto/channel.h index d13169bd67..e2424f1474 100644 --- a/include/proto/channel.h +++ b/include/proto/channel.h @@ -103,11 +103,12 @@ static inline unsigned int channel_is_empty(struct channel *c) return !(c->buf->o | (long)c->pipe); } -/* Returns non-zero if the buffer input has all of its reserve available. This - * is used to decide when a request or response may be parsed when some data - * from a previous exchange might still be present. +/* Returns non-zero if the channel is rewritable, which means that the buffer + * it is attached to has at least bytes immediately available. + * This is used to decide when a request or response may be parsed when some + * data from a previous exchange might still be present. */ -static inline int channel_reserved(const struct channel *chn) +static inline int channel_is_rewritable(const struct channel *chn) { int rem = chn->buf->size; diff --git a/src/proto_http.c b/src/proto_http.c index 4b14b88fa8..e14b1d69c7 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -2502,7 +2502,7 @@ int http_wait_for_request(struct session *s, struct channel *req, int an_bit) */ if (buffer_not_empty(req->buf) && msg->msg_state < HTTP_MSG_ERROR) { if (txn->flags & TX_NOT_FIRST) { - if (unlikely(!channel_reserved(req))) { + if (unlikely(!channel_is_rewritable(req))) { if (req->flags & (CF_SHUTW|CF_SHUTW_NOW|CF_WRITE_ERROR|CF_WRITE_TIMEOUT)) goto failed_keep_alive; /* some data has still not left the buffer, wake us once that's done */ @@ -2524,7 +2524,7 @@ int http_wait_for_request(struct session *s, struct channel *req, int an_bit) * keep-alive requests. */ if ((txn->flags & TX_NOT_FIRST) && - unlikely(!channel_reserved(s->rep) || + unlikely(!channel_is_rewritable(s->rep) || bi_end(s->rep->buf) < b_ptr(s->rep->buf, txn->rsp.next) || bi_end(s->rep->buf) > s->rep->buf->data + s->rep->buf->size - global.tune.maxrewrite)) { if (s->rep->buf->o) { @@ -5673,7 +5673,7 @@ int http_wait_for_response(struct session *s, struct channel *rep, int an_bit) * data later, which is much more complicated. */ if (buffer_not_empty(rep->buf) && msg->msg_state < HTTP_MSG_ERROR) { - if (unlikely(!channel_reserved(rep))) { + if (unlikely(!channel_is_rewritable(rep))) { /* some data has still not left the buffer, wake us once that's done */ if (rep->flags & (CF_SHUTW|CF_SHUTW_NOW|CF_WRITE_ERROR|CF_WRITE_TIMEOUT)) goto abort_response;