mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-20 21:31:28 +02:00
MINOR: buffer: remove bi_end()
It was replaced by ci_tail() when the channel is known, or b_tail() in other cases.
This commit is contained in:
parent
41e38ac0ee
commit
8f9c72d301
@ -105,18 +105,6 @@ static inline void bo_del(struct buffer *b, unsigned int del)
|
||||
b->o -= del;
|
||||
}
|
||||
|
||||
/* Returns the end of the input data in a buffer (pointer to next
|
||||
* insertion point).
|
||||
*/
|
||||
static inline char *bi_end(const struct buffer *b)
|
||||
{
|
||||
char *ret = b->p + b->i;
|
||||
|
||||
if (ret >= b->data + b->size)
|
||||
ret -= b->size;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Returns the amount of output data that can contiguously be read at once */
|
||||
static inline int bo_contig_data(const struct buffer *b)
|
||||
{
|
||||
@ -448,7 +436,7 @@ static inline void bi_putchr(struct buffer *b, char c)
|
||||
{
|
||||
if (buffer_len(b) == b->size)
|
||||
return;
|
||||
*bi_end(b) = c;
|
||||
*b_tail(b) = c;
|
||||
b->i++;
|
||||
}
|
||||
|
||||
@ -470,7 +458,7 @@ static inline int bi_putblk(struct buffer *b, const char *blk, int len)
|
||||
if (half > len)
|
||||
half = len;
|
||||
|
||||
memcpy(bi_end(b), blk, half);
|
||||
memcpy(b_tail(b), blk, half);
|
||||
if (len > half)
|
||||
memcpy(b_ptr(b, b->i + half), blk + half, len - half);
|
||||
b->i += len;
|
||||
|
16
src/buffer.c
16
src/buffer.c
@ -86,16 +86,16 @@ int buffer_replace2(struct buffer *b, char *pos, char *end, const char *str, int
|
||||
|
||||
delta = len - (end - pos);
|
||||
|
||||
if (bi_end(b) + delta > b->data + b->size)
|
||||
if (b_tail(b) + delta > b->data + b->size)
|
||||
return 0; /* no space left */
|
||||
|
||||
if (buffer_not_empty(b) &&
|
||||
bi_end(b) + delta > b_head(b) &&
|
||||
b_head(b) >= bi_end(b))
|
||||
b_tail(b) + delta > b_head(b) &&
|
||||
b_head(b) >= b_tail(b))
|
||||
return 0; /* no space left before wrapping data */
|
||||
|
||||
/* first, protect the end of the buffer */
|
||||
memmove(end + delta, end, bi_end(b) - end);
|
||||
memmove(end + delta, end, b_tail(b) - end);
|
||||
|
||||
/* now, copy str over pos */
|
||||
if (len)
|
||||
@ -125,16 +125,16 @@ int buffer_insert_line2(struct buffer *b, char *pos, const char *str, int len)
|
||||
|
||||
delta = len + 2;
|
||||
|
||||
if (bi_end(b) + delta >= b->data + b->size)
|
||||
if (b_tail(b) + delta >= b->data + b->size)
|
||||
return 0; /* no space left */
|
||||
|
||||
if (buffer_not_empty(b) &&
|
||||
bi_end(b) + delta > b_head(b) &&
|
||||
b_head(b) >= bi_end(b))
|
||||
b_tail(b) + delta > b_head(b) &&
|
||||
b_head(b) >= b_tail(b))
|
||||
return 0; /* no space left before wrapping data */
|
||||
|
||||
/* first, protect the end of the buffer */
|
||||
memmove(pos + delta, pos, bi_end(b) - pos);
|
||||
memmove(pos + delta, pos, b_tail(b) - pos);
|
||||
|
||||
/* now, copy str over pos */
|
||||
if (len && str) {
|
||||
|
@ -552,7 +552,7 @@ static void http_cache_io_handler(struct appctx *appctx)
|
||||
/* buffer are aligned there, should be fine */
|
||||
if (appctx->st0 == HTTP_CACHE_INIT) {
|
||||
int len = first->len - sizeof(struct cache_entry);
|
||||
if ((shctx_row_data_get(shctx, first, (unsigned char *)bi_end(res->buf), sizeof(struct cache_entry), len)) != 0) {
|
||||
if ((shctx_row_data_get(shctx, first, (unsigned char *)ci_tail(res), sizeof(struct cache_entry), len)) != 0) {
|
||||
/* should never get there, because at the moment, a
|
||||
* cache object can never be bigger than a buffer */
|
||||
abort();
|
||||
|
@ -117,7 +117,7 @@ int ci_putchr(struct channel *chn, char c)
|
||||
if (!channel_may_recv(chn))
|
||||
return -1;
|
||||
|
||||
*bi_end(chn->buf) = c;
|
||||
*ci_tail(chn) = c;
|
||||
|
||||
chn->buf->i++;
|
||||
chn->flags |= CF_READ_PARTIAL;
|
||||
@ -167,7 +167,7 @@ int ci_putblk(struct channel *chn, const char *blk, int len)
|
||||
|
||||
/* OK so the data fits in the buffer in one or two blocks */
|
||||
max = bi_contig_space(chn->buf);
|
||||
memcpy(bi_end(chn->buf), blk, MIN(len, max));
|
||||
memcpy(ci_tail(chn), blk, MIN(len, max));
|
||||
if (len > max)
|
||||
memcpy(chn->buf->data, blk + max, len - max);
|
||||
|
||||
|
@ -221,7 +221,7 @@ static int identity_init(struct comp_ctx **comp_ctx, int level)
|
||||
*/
|
||||
static int identity_add_data(struct comp_ctx *comp_ctx, const char *in_data, int in_len, struct buffer *out)
|
||||
{
|
||||
char *out_data = bi_end(out);
|
||||
char *out_data = b_tail(out);
|
||||
int out_len = out->size - buffer_len(out);
|
||||
|
||||
if (out_len < in_len)
|
||||
@ -307,7 +307,7 @@ static int rfc195x_add_data(struct comp_ctx *comp_ctx, const char *in_data, int
|
||||
return -1; /* no memory */
|
||||
}
|
||||
b_reset(tmpbuf);
|
||||
memcpy(bi_end(tmpbuf), comp_ctx->direct_ptr, comp_ctx->direct_len);
|
||||
memcpy(b_tail(tmpbuf), comp_ctx->direct_ptr, comp_ctx->direct_len);
|
||||
tmpbuf->i += comp_ctx->direct_len;
|
||||
comp_ctx->direct_ptr = NULL;
|
||||
comp_ctx->direct_len = 0;
|
||||
@ -317,7 +317,7 @@ static int rfc195x_add_data(struct comp_ctx *comp_ctx, const char *in_data, int
|
||||
|
||||
if (comp_ctx->queued) {
|
||||
/* data already pending */
|
||||
memcpy(bi_end(comp_ctx->queued), in_data, in_len);
|
||||
memcpy(b_tail(comp_ctx->queued), in_data, in_len);
|
||||
comp_ctx->queued->i += in_len;
|
||||
return in_len;
|
||||
}
|
||||
@ -350,10 +350,10 @@ static int rfc195x_flush_or_finish(struct comp_ctx *comp_ctx, struct buffer *out
|
||||
out_len = out->i;
|
||||
|
||||
if (in_ptr)
|
||||
out->i += slz_encode(strm, bi_end(out), in_ptr, in_len, !finish);
|
||||
out->i += slz_encode(strm, b_tail(out), in_ptr, in_len, !finish);
|
||||
|
||||
if (finish)
|
||||
out->i += slz_finish(strm, bi_end(out));
|
||||
out->i += slz_finish(strm, b_tail(out));
|
||||
|
||||
out_len = out->i - out_len;
|
||||
|
||||
@ -569,7 +569,7 @@ static int deflate_add_data(struct comp_ctx *comp_ctx, const char *in_data, int
|
||||
{
|
||||
int ret;
|
||||
z_stream *strm = &comp_ctx->strm;
|
||||
char *out_data = bi_end(out);
|
||||
char *out_data = b_tail(out);
|
||||
int out_len = out->size - buffer_len(out);
|
||||
|
||||
if (in_len <= 0)
|
||||
@ -602,7 +602,7 @@ static int deflate_flush_or_finish(struct comp_ctx *comp_ctx, struct buffer *out
|
||||
|
||||
strm->next_in = NULL;
|
||||
strm->avail_in = 0;
|
||||
strm->next_out = (unsigned char *)bi_end(out);
|
||||
strm->next_out = (unsigned char *)b_tail(out);
|
||||
strm->avail_out = out->size - buffer_len(out);
|
||||
|
||||
ret = deflate(strm, flag);
|
||||
|
@ -207,9 +207,9 @@ comp_http_data(struct stream *s, struct filter *filter, struct http_msg *msg)
|
||||
|
||||
c_adv(chn, *nxt);
|
||||
block = ci_contig_data(chn);
|
||||
memcpy(bi_end(tmpbuf), ci_head(chn), block);
|
||||
memcpy(b_tail(tmpbuf), ci_head(chn), block);
|
||||
if (len > block)
|
||||
memcpy(bi_end(tmpbuf)+block, buf->data, len-block);
|
||||
memcpy(b_tail(tmpbuf)+block, buf->data, len-block);
|
||||
c_rew(chn, *nxt);
|
||||
|
||||
tmpbuf->i += len;
|
||||
|
2
src/h1.c
2
src/h1.c
@ -1292,7 +1292,7 @@ int http_forward_trailers(struct http_msg *msg)
|
||||
while (1) {
|
||||
const char *p1 = NULL, *p2 = NULL;
|
||||
const char *start = b_ptr(buf, msg->next + msg->sol);
|
||||
const char *stop = bi_end(buf);
|
||||
const char *stop = b_tail(buf);
|
||||
const char *ptr = start;
|
||||
int bytes = 0;
|
||||
|
||||
|
@ -2712,7 +2712,7 @@ static int h2_frt_decode_headers(struct h2s *h2s, struct buffer *buf, int count)
|
||||
|
||||
/* OK now we have our header list in <list> */
|
||||
msgf = (h2c->dff & H2_F_DATA_END_STREAM) ? 0 : H2_MSGF_BODY;
|
||||
outlen = h2_make_h1_request(list, bi_end(buf), try, &msgf);
|
||||
outlen = h2_make_h1_request(list, b_tail(buf), try, &msgf);
|
||||
|
||||
if (outlen < 0) {
|
||||
h2c_error(h2c, H2_ERR_COMPRESSION_ERROR);
|
||||
|
@ -1650,8 +1650,8 @@ int http_wait_for_request(struct stream *s, struct channel *req, int an_bit)
|
||||
req->flags |= CF_WAKE_WRITE;
|
||||
return 0;
|
||||
}
|
||||
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))
|
||||
if (unlikely(ci_tail(req) < b_ptr(req->buf, msg->next) ||
|
||||
ci_tail(req) > req->buf->data + req->buf->size - global.tune.maxrewrite))
|
||||
channel_slow_realign(req, trash.str);
|
||||
}
|
||||
|
||||
@ -5137,8 +5137,8 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
|
||||
return 0;
|
||||
}
|
||||
|
||||
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))
|
||||
if (unlikely(ci_tail(rep) < b_ptr(rep->buf, msg->next) ||
|
||||
ci_tail(rep) > rep->buf->data + rep->buf->size - global.tune.maxrewrite))
|
||||
channel_slow_realign(rep, trash.str);
|
||||
|
||||
if (likely(msg->next < rep->buf->i))
|
||||
|
@ -297,7 +297,7 @@ static int raw_sock_to_buf(struct connection *conn, struct buffer *buf, int coun
|
||||
if (try > count)
|
||||
try = count;
|
||||
|
||||
ret = recv(conn->handle.fd, bi_end(buf), try, 0);
|
||||
ret = recv(conn->handle.fd, b_tail(buf), try, 0);
|
||||
|
||||
if (ret > 0) {
|
||||
buf->i += ret;
|
||||
|
@ -5376,7 +5376,7 @@ static int ssl_sock_to_buf(struct connection *conn, struct buffer *buf, int coun
|
||||
try = count;
|
||||
if (((conn->flags & (CO_FL_EARLY_SSL_HS | CO_FL_EARLY_DATA)) == CO_FL_EARLY_SSL_HS) &&
|
||||
conn->tmp_early_data != -1) {
|
||||
*bi_end(buf) = conn->tmp_early_data;
|
||||
*b_tail(buf) = conn->tmp_early_data;
|
||||
done++;
|
||||
try--;
|
||||
count--;
|
||||
@ -5390,7 +5390,7 @@ static int ssl_sock_to_buf(struct connection *conn, struct buffer *buf, int coun
|
||||
size_t read_length;
|
||||
|
||||
ret = SSL_read_early_data(conn->xprt_ctx,
|
||||
bi_end(buf), try, &read_length);
|
||||
b_tail(buf), try, &read_length);
|
||||
if (ret == SSL_READ_EARLY_DATA_SUCCESS &&
|
||||
read_length > 0)
|
||||
conn->flags |= CO_FL_EARLY_DATA;
|
||||
@ -5411,7 +5411,7 @@ static int ssl_sock_to_buf(struct connection *conn, struct buffer *buf, int coun
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
ret = SSL_read(conn->xprt_ctx, bi_end(buf), try);
|
||||
ret = SSL_read(conn->xprt_ctx, b_tail(buf), try);
|
||||
#ifdef OPENSSL_IS_BORINGSSL
|
||||
if (conn->flags & CO_FL_EARLY_SSL_HS) {
|
||||
if (SSL_in_early_data(conn->xprt_ctx)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user