From: Willy Tarreau Date: Fri, 15 Jun 2018 09:11:53 +0000 (+0200) Subject: MINOR: buffer: convert most b_ptr() calls to c_ptr() X-Git-Tag: v1.9-dev1~140 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=188e2307043872f9181013e84f00e30d8d3ca0ad;p=thirdparty%2Fhaproxy.git MINOR: buffer: convert most b_ptr() calls to c_ptr() The latter uses the channel wherever a channel is known. --- diff --git a/src/backend.c b/src/backend.c index 70972b437b..ea266f36cc 100644 --- a/src/backend.c +++ b/src/backend.c @@ -322,7 +322,7 @@ static struct server *get_server_ph_post(struct stream *s) struct proxy *px = s->be; unsigned int plen = px->url_param_len; unsigned long len = http_body_bytes(msg); - const char *params = b_ptr(req->buf, -http_data_rewind(msg)); + const char *params = c_ptr(req, -http_data_rewind(msg)); const char *p = params; const char *start, *end; @@ -412,7 +412,7 @@ static struct server *get_server_hh(struct stream *s) ctx.idx = 0; /* if the message is chunked, we skip the chunk size, but use the value as len */ - http_find_header2(px->hh_name, plen, b_ptr(s->req.buf, -http_hdr_rewind(&txn->req)), &txn->hdr_idx, &ctx); + http_find_header2(px->hh_name, plen, c_ptr(&s->req, -http_hdr_rewind(&txn->req)), &txn->hdr_idx, &ctx); /* if the header is not found or empty, let's fallback to round robin */ if (!ctx.idx || !ctx.vlen) @@ -669,7 +669,7 @@ int assign_server(struct stream *s) if (!s->txn || s->txn->req.msg_state < HTTP_MSG_BODY) break; srv = get_server_uh(s->be, - b_ptr(s->req.buf, -http_uri_rewind(&s->txn->req)), + c_ptr(&s->req, -http_uri_rewind(&s->txn->req)), s->txn->req.sl.rq.u_l); break; @@ -679,7 +679,7 @@ int assign_server(struct stream *s) break; srv = get_server_ph(s->be, - b_ptr(s->req.buf, -http_uri_rewind(&s->txn->req)), + c_ptr(&s->req, -http_uri_rewind(&s->txn->req)), s->txn->req.sl.rq.u_l); if (!srv && s->txn->meth == HTTP_METH_POST) diff --git a/src/channel.c b/src/channel.c index ad309b8e15..b7200246d5 100644 --- a/src/channel.c +++ b/src/channel.c @@ -98,7 +98,7 @@ int co_inject(struct channel *chn, const char *msg, int len) memcpy(chn->buf->p, msg, len); chn->buf->o += len; - chn->buf->p = b_ptr(chn->buf, len); + chn->buf->p = c_ptr(chn, len); chn->total += len; return -1; } diff --git a/src/h1.c b/src/h1.c index 8b8545d4e8..f0701163a3 100644 --- a/src/h1.c +++ b/src/h1.c @@ -14,6 +14,7 @@ #include #include +#include #include #include @@ -1291,7 +1292,7 @@ int http_forward_trailers(struct http_msg *msg) msg->sol = 0; while (1) { const char *p1 = NULL, *p2 = NULL; - const char *start = b_ptr(buf, msg->next + msg->sol); + const char *start = c_ptr(msg->chn, msg->next + msg->sol); const char *stop = b_tail(buf); const char *ptr = start; int bytes = 0; diff --git a/src/proto_http.c b/src/proto_http.c index 7b7f46c68f..5d7fc988ad 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -1111,7 +1111,7 @@ void http_perform_server_redirect(struct stream *s, struct stream_interface *si) c_rew(&s->req, rewind = http_hdr_rewind(&txn->req)); path = http_get_path(txn); - len = buffer_count(s->req.buf, path, b_ptr(s->req.buf, txn->req.sl.rq.u + txn->req.sl.rq.u_l)); + len = buffer_count(s->req.buf, path, c_ptr(&s->req, txn->req.sl.rq.u + txn->req.sl.rq.u_l)); c_adv(&s->req, rewind); @@ -1650,7 +1650,7 @@ int http_wait_for_request(struct stream *s, struct channel *req, int an_bit) req->flags |= CF_WAKE_WRITE; return 0; } - if (unlikely(ci_tail(req) < b_ptr(req->buf, msg->next) || + if (unlikely(ci_tail(req) < c_ptr(req, msg->next) || ci_tail(req) > req->buf->data + req->buf->size - global.tune.maxrewrite)) channel_slow_realign(req, trash.str); } @@ -5137,7 +5137,7 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit) return 0; } - if (unlikely(ci_tail(rep) < b_ptr(rep->buf, msg->next) || + if (unlikely(ci_tail(rep) < c_ptr(rep, msg->next) || ci_tail(rep) > rep->buf->data + rep->buf->size - global.tune.maxrewrite)) channel_slow_realign(rep, trash.str); @@ -9919,7 +9919,7 @@ smp_fetch_body(const struct arg *args, struct sample *smp, const char *kw, void msg = &smp->strm->txn->rsp; len = http_body_bytes(msg); - body = b_ptr(msg->chn->buf, -http_data_rewind(msg)); + body = c_ptr(msg->chn, -http_data_rewind(msg)); block1 = len; if (block1 > msg->chn->buf->data + msg->chn->buf->size - body) @@ -11390,7 +11390,7 @@ smp_fetch_body_param(const struct arg *args, struct sample *smp, const char *kw, msg = &smp->strm->txn->rsp; len = http_body_bytes(msg); - body = b_ptr(msg->chn->buf, -http_data_rewind(msg)); + body = c_ptr(msg->chn, -http_data_rewind(msg)); block1 = len; if (block1 > msg->chn->buf->data + msg->chn->buf->size - body)