]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: channel: make channel_slow_realign() take a swap buffer
authorWilly Tarreau <w@1wt.eu>
Thu, 12 Jul 2018 08:57:15 +0000 (10:57 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 19 Jul 2018 14:23:40 +0000 (16:23 +0200)
The few call places where it's used can use the trash as a swap buffer,
which is made for this exact purpose. This way we can rely on the
generic b_slow_realign() call.

include/proto/channel.h
src/hlua.c
src/proto_http.c

index c7135de010c2461e1667e4198a42343d98cd408d..4e5b90b3005ecde52a0af71e89a169ff7b7707d9 100644 (file)
@@ -707,9 +707,9 @@ static inline void channel_truncate(struct channel *chn)
  * it allows the largest inputs to be processed at once and ensures that once
  * the output data leaves, the whole buffer is available at once.
  */
-static inline void channel_slow_realign(struct channel *chn)
+static inline void channel_slow_realign(struct channel *chn, char *swap)
 {
-       return buffer_slow_realign(chn->buf, co_data(chn));
+       return b_slow_realign(chn->buf, swap, co_data(chn));
 }
 
 /*
index cdb5ff69c673f7abf1a7b77b3952ec63124ebc84..f8170062e992f09e4767e894b6eb9518f8d5b72d 100644 (file)
@@ -3041,7 +3041,7 @@ __LJMP static int hlua_channel_send_yield(lua_State *L, int status, lua_KContext
         * detects a non contiguous buffer and realign it.
         */
        if (bi_space_for_replace(chn->buf) < max)
-               channel_slow_realign(chn);
+               channel_slow_realign(chn, trash.str);
 
        /* Copy input data in the buffer. */
        max = buffer_replace2(chn->buf, chn->buf->p, chn->buf->p, str + l, max);
index a4db33a48ebcec3703f557a9bef6733b7d2ea94b..67598e58a8cd9156be8b5236e54a9024bb11c0e0 100644 (file)
@@ -1652,7 +1652,7 @@ int http_wait_for_request(struct stream *s, struct channel *req, int an_bit)
                        }
                        if (unlikely(bi_end(req->buf) < b_ptr(req->buf, msg->next) ||
                                     bi_end(req->buf) > req->buf->data + req->buf->size - global.tune.maxrewrite))
-                               channel_slow_realign(req);
+                               channel_slow_realign(req, trash.str);
                }
 
                if (likely(msg->next < req->buf->i)) /* some unparsed data are available */
@@ -5139,7 +5139,7 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
 
                if (unlikely(bi_end(rep->buf) < b_ptr(rep->buf, msg->next) ||
                             bi_end(rep->buf) > rep->buf->data + rep->buf->size - global.tune.maxrewrite))
-                       channel_slow_realign(rep);
+                       channel_slow_realign(rep, trash.str);
 
                if (likely(msg->next < rep->buf->i))
                        http_msg_analyzer(msg, &txn->hdr_idx);
@@ -9517,7 +9517,7 @@ int smp_prefetch_http(struct proxy *px, struct stream *s, unsigned int opt,
                 */
                if (s->req.buf->p > s->req.buf->data &&
                    s->req.buf->i + s->req.buf->p > s->req.buf->data + s->req.buf->size - global.tune.maxrewrite)
-                       channel_slow_realign(&s->req);
+                       channel_slow_realign(&s->req, trash.str);
 
                if (unlikely(txn->req.msg_state < HTTP_MSG_BODY)) {
                        if (msg->msg_state == HTTP_MSG_ERROR)