]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: buffer: remove bo_contig_data()
authorWilly Tarreau <w@1wt.eu>
Thu, 7 Jun 2018 17:03:40 +0000 (19:03 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 19 Jul 2018 14:23:40 +0000 (16:23 +0200)
The two call places now make use of b_contig_data(0) and check by
themselves that the returned size is no larger than the scheduled
output data.

include/common/buffer.h
src/flt_http_comp.c
src/ssl_sock.c

index 0c8eeb019988bcfc65fdca5648a263fd80458e53..8638bd6849eaa677c208a5fe91ba52481fe9435b 100644 (file)
@@ -105,16 +105,6 @@ static inline void bo_del(struct buffer *b, unsigned int del)
        b->o -= del;
 }
 
-/* Returns the amount of output data that can contiguously be read at once */
-static inline int bo_contig_data(const struct buffer *b)
-{
-       char *beg = b->p - b->o;
-
-       if (beg < b->data)
-               return b->data - beg;
-       return b->o;
-}
-
 /* Return the amount of bytes that can be written into the input area at once
  * including reserved space which may be overwritten (this is the caller
  * responsibility to know if the reserved space is protected or not).
index 0ccf23b12206dec51a60c25d8381c1a2316d2999..99b18cc4f722befe2f8bb3cee1ef568c2fa84847 100644 (file)
@@ -720,7 +720,10 @@ http_compression_buffer_end(struct comp_state *st, struct stream *s,
 
        /* Copy previous data from ib->o into ob->o */
        if (ib->o > 0) {
-               left = bo_contig_data(ib);
+               left = b_contig_data(ib, 0);
+               if (left > ib->o)
+                       left = ib->o;
+
                memcpy(ob->p - ob->o, b_head(ib), left);
                if (ib->o - left) /* second part of the buffer */
                        memcpy(ob->p - ob->o + left, ib->data, ib->o - left);
index 56d2eed7fa5d88b1f86a49f3b04c291351f82ba9..e694c8721e48620bc671aec9a34c1820301678e8 100644 (file)
@@ -5526,7 +5526,9 @@ static int ssl_sock_from_buf(struct connection *conn, struct buffer *buf, int fl
                size_t written_data;
 #endif
 
-               try = bo_contig_data(buf);
+               try = b_contig_data(buf, 0);
+               if (try > buf->o)
+                       try = buf->o;
 
                if (!(flags & CO_SFL_STREAMER) &&
                    !(conn->xprt_st & SSL_SOCK_SEND_UNLIMITED) &&