]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: buffer: convert most b_ptr() calls to c_ptr()
authorWilly Tarreau <w@1wt.eu>
Fri, 15 Jun 2018 09:11:53 +0000 (11:11 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 19 Jul 2018 14:23:40 +0000 (16:23 +0200)
The latter uses the channel wherever a channel is known.

src/backend.c
src/channel.c
src/h1.c
src/proto_http.c

index 70972b437b81decb9cd521f15126bc32b7be89e1..ea266f36cc59d639e946d9d9ebd45f3f3fdb691a 100644 (file)
@@ -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)
index ad309b8e15f278a8c4e43945a2c4ce1608adac29..b7200246d5e80ffcec781b7c262f9225fb03ea08 100644 (file)
@@ -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;
 }
index 8b8545d4e85325f1a6ac9f21c387c384762eabd4..f0701163a3fbac162f43db335349ac47834ef61e 100644 (file)
--- a/src/h1.c
+++ b/src/h1.c
@@ -14,6 +14,7 @@
 #include <common/config.h>
 #include <common/http-hdr.h>
 
+#include <proto/channel.h>
 #include <proto/h1.h>
 #include <proto/hdr_idx.h>
 
@@ -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;
index 7b7f46c68f2881fd14f40629e97b1706370e1e5c..5d7fc988add519477ed0a0a99043552cb4a03761 100644 (file)
@@ -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)