mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-11-09 04:51:01 +01:00
MINOR: buffer: replace calls to buffer_space_wraps() with b_space_wraps()
And remove the unused function.
This commit is contained in:
parent
bcbd39370f
commit
aa7af7213d
@ -217,37 +217,6 @@ static inline int buffer_empty(const struct buffer *buf)
|
|||||||
return !buffer_not_empty(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
|
/* 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
|
* 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
|
* that data that are scheduled for output are considered as potential free
|
||||||
|
|||||||
12
src/mux_h2.c
12
src/mux_h2.c
@ -2684,7 +2684,7 @@ static int h2_frt_decode_headers(struct h2s *h2s, struct buffer *buf, int count)
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unlikely(buffer_space_wraps(buf))) {
|
if (unlikely(b_space_wraps(buf))) {
|
||||||
/* it doesn't fit and the buffer is fragmented,
|
/* it doesn't fit and the buffer is fragmented,
|
||||||
* so let's defragment it and try again.
|
* 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.size = bo_contig_space(h2c->mbuf);
|
||||||
outbuf.len = 0;
|
outbuf.len = 0;
|
||||||
|
|
||||||
if (outbuf.size >= 9 || !buffer_space_wraps(h2c->mbuf))
|
if (outbuf.size >= 9 || !b_space_wraps(h2c->mbuf))
|
||||||
break;
|
break;
|
||||||
realign_again:
|
realign_again:
|
||||||
b_slow_realign(h2c->mbuf, trash.str, h2c->mbuf->o);
|
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];
|
outbuf.str[outbuf.len++] = list[0].v.ptr[2];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (buffer_space_wraps(h2c->mbuf))
|
if (b_space_wraps(h2c->mbuf))
|
||||||
goto realign_again;
|
goto realign_again;
|
||||||
|
|
||||||
h2c->flags |= H2_CF_MUX_MFULL;
|
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)) {
|
if (!hpack_encode_header(&outbuf, list[hdr].n, list[hdr].v)) {
|
||||||
/* output full */
|
/* output full */
|
||||||
if (buffer_space_wraps(h2c->mbuf))
|
if (b_space_wraps(h2c->mbuf))
|
||||||
goto realign_again;
|
goto realign_again;
|
||||||
|
|
||||||
h2c->flags |= H2_CF_MUX_MFULL;
|
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.size = bo_contig_space(h2c->mbuf);
|
||||||
outbuf.len = 0;
|
outbuf.len = 0;
|
||||||
|
|
||||||
if (outbuf.size >= 9 || !buffer_space_wraps(h2c->mbuf))
|
if (outbuf.size >= 9 || !b_space_wraps(h2c->mbuf))
|
||||||
break;
|
break;
|
||||||
realign_again:
|
realign_again:
|
||||||
b_slow_realign(h2c->mbuf, trash.str, h2c->mbuf->o);
|
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
|
/* we have an opportunity for enlarging the too small
|
||||||
* available space, let's try.
|
* available space, let's try.
|
||||||
*/
|
*/
|
||||||
if (buffer_space_wraps(h2c->mbuf))
|
if (b_space_wraps(h2c->mbuf))
|
||||||
goto realign_again;
|
goto realign_again;
|
||||||
size = outbuf.size - 9;
|
size = outbuf.size - 9;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user