]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: buffer: replace calls to buffer_space_wraps() with b_space_wraps()
authorWilly Tarreau <w@1wt.eu>
Thu, 12 Jul 2018 08:33:12 +0000 (10:33 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 19 Jul 2018 14:23:40 +0000 (16:23 +0200)
And remove the unused function.

include/common/buffer.h
src/mux_h2.c

index d7687f99dfe2ca36fa44e299f31ba73b78b4d405..ac56ae9c01e8bc12258274fb6a2d3e06c4d7bfbd 100644 (file)
@@ -217,37 +217,6 @@ static inline int buffer_empty(const struct buffer *buf)
        return !buffer_not_empty(buf);
 }
 
-/* Return non-zero only if the buffer's free space wraps :
- *  [     |oooo|           ]    => yes
- *  [          |iiii|      ]    => yes
- *  [     |oooo|iiii|      ]    => yes
- *  [oooo|                 ]    => no
- *  [                 |oooo]    => no
- *  [iiii|                 ]    => no
- *  [                 |iiii]    => no
- *  [oooo|iiii|            ]    => no
- *  [            |oooo|iiii]    => no
- *  [iiii|            |oooo]    => no
- *  [oo|iiii|           |oo]    => no
- *  [iiii|           |oo|ii]    => no
- *  [oooooooooo|iiiiiiiiiii]    => no
- *  [iiiiiiiiiiiii|oooooooo]    => no
- *
- *  So the only case where the buffer does not wrap is when there's data either
- *  at the beginning or at the end of the buffer. Thus we have this :
- *  - if (p+i >= size) ==> doesn't wrap
- *  - if (p-data <= o) ==> doesn't wrap
- *  - otherwise wraps
- */
-static inline int buffer_space_wraps(const struct buffer *buf)
-{
-       if (buf->p + buf->i >= buf->data + buf->size)
-               return 0;
-       if (buf->p <= buf->data + buf->o)
-               return 0;
-       return 1;
-}
-
 /* Returns non-zero if the buffer's INPUT is considered full, which means that
  * it holds at least as much INPUT data as (size - reserve). This also means
  * that data that are scheduled for output are considered as potential free
index 9a1d71867f36853bdf87da5047f63400c2592fe6..8aab234e5dced96c912ce1b0e73de052b3bd294b 100644 (file)
@@ -2684,7 +2684,7 @@ static int h2_frt_decode_headers(struct h2s *h2s, struct buffer *buf, int count)
                goto fail;
        }
 
-       if (unlikely(buffer_space_wraps(buf))) {
+       if (unlikely(b_space_wraps(buf))) {
                /* it doesn't fit and the buffer is fragmented,
                 * so let's defragment it and try again.
                 */
@@ -2992,7 +2992,7 @@ static int h2s_frt_make_resp_headers(struct h2s *h2s, struct buffer *buf)
                outbuf.size = bo_contig_space(h2c->mbuf);
                outbuf.len = 0;
 
-               if (outbuf.size >= 9 || !buffer_space_wraps(h2c->mbuf))
+               if (outbuf.size >= 9 || !b_space_wraps(h2c->mbuf))
                        break;
        realign_again:
                b_slow_realign(h2c->mbuf, trash.str, h2c->mbuf->o);
@@ -3030,7 +3030,7 @@ static int h2s_frt_make_resp_headers(struct h2s *h2s, struct buffer *buf)
                outbuf.str[outbuf.len++] = list[0].v.ptr[2];
        }
        else {
-               if (buffer_space_wraps(h2c->mbuf))
+               if (b_space_wraps(h2c->mbuf))
                        goto realign_again;
 
                h2c->flags |= H2_CF_MUX_MFULL;
@@ -3054,7 +3054,7 @@ static int h2s_frt_make_resp_headers(struct h2s *h2s, struct buffer *buf)
 
                if (!hpack_encode_header(&outbuf, list[hdr].n, list[hdr].v)) {
                        /* output full */
-                       if (buffer_space_wraps(h2c->mbuf))
+                       if (b_space_wraps(h2c->mbuf))
                                goto realign_again;
 
                        h2c->flags |= H2_CF_MUX_MFULL;
@@ -3150,7 +3150,7 @@ static int h2s_frt_make_resp_data(struct h2s *h2s, struct buffer *buf)
                outbuf.size = bo_contig_space(h2c->mbuf);
                outbuf.len = 0;
 
-               if (outbuf.size >= 9 || !buffer_space_wraps(h2c->mbuf))
+               if (outbuf.size >= 9 || !b_space_wraps(h2c->mbuf))
                        break;
        realign_again:
                b_slow_realign(h2c->mbuf, trash.str, h2c->mbuf->o);
@@ -3250,7 +3250,7 @@ static int h2s_frt_make_resp_data(struct h2s *h2s, struct buffer *buf)
                /* we have an opportunity for enlarging the too small
                 * available space, let's try.
                 */
-               if (buffer_space_wraps(h2c->mbuf))
+               if (b_space_wraps(h2c->mbuf))
                        goto realign_again;
                size = outbuf.size - 9;
        }