mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-31 10:31:46 +00:00
MINOR: buffer: Use b_add()/bo_add() instead of accessing b->i/b->o.
Use the newly available functions instead of using the buffer fields directly.
This commit is contained in:
parent
591d445049
commit
acd1403794
@ -101,7 +101,7 @@ int buffer_replace2(struct buffer *b, char *pos, char *end, const char *str, int
|
||||
if (len)
|
||||
memcpy(pos, str, len);
|
||||
|
||||
b->i += delta;
|
||||
b_add(b, delta);
|
||||
b_realign_if_empty(b);
|
||||
|
||||
return delta;
|
||||
@ -141,7 +141,7 @@ int buffer_insert_line2(struct buffer *b, char *pos, const char *str, int len)
|
||||
pos[len + 1] = '\n';
|
||||
}
|
||||
|
||||
b->i += delta;
|
||||
b_add(b, delta);
|
||||
return delta;
|
||||
}
|
||||
|
||||
|
@ -560,7 +560,7 @@ static void http_cache_io_handler(struct appctx *appctx)
|
||||
si_applet_cant_put(si);
|
||||
goto out;
|
||||
}
|
||||
res->buf->i += len;
|
||||
b_add(res->buf, len);
|
||||
res->total += len;
|
||||
appctx->st0 = HTTP_CACHE_FWD;
|
||||
}
|
||||
|
@ -96,9 +96,9 @@ int co_inject(struct channel *chn, const char *msg, int len)
|
||||
if (len > max)
|
||||
return max;
|
||||
|
||||
memcpy(chn->buf->p, msg, len);
|
||||
chn->buf->o += len;
|
||||
chn->buf->p = c_ptr(chn, len);
|
||||
memcpy(b_tail(chn->buf), msg, len);
|
||||
b_add(chn->buf, len);
|
||||
c_adv(chn, len);
|
||||
chn->total += len;
|
||||
return -1;
|
||||
}
|
||||
@ -171,7 +171,7 @@ int ci_putblk(struct channel *chn, const char *blk, int len)
|
||||
if (len > max)
|
||||
memcpy(b_orig(chn->buf), blk + max, len - max);
|
||||
|
||||
chn->buf->i += len;
|
||||
b_add(chn->buf, len);
|
||||
chn->total += len;
|
||||
if (chn->to_forward) {
|
||||
unsigned long fwd = len;
|
||||
|
@ -229,7 +229,7 @@ static int identity_add_data(struct comp_ctx *comp_ctx, const char *in_data, int
|
||||
|
||||
memcpy(out_data, in_data, in_len);
|
||||
|
||||
out->i += in_len;
|
||||
b_add(out, in_len);
|
||||
|
||||
return in_len;
|
||||
}
|
||||
@ -308,7 +308,7 @@ static int rfc195x_add_data(struct comp_ctx *comp_ctx, const char *in_data, int
|
||||
}
|
||||
b_reset(tmpbuf);
|
||||
memcpy(b_tail(tmpbuf), comp_ctx->direct_ptr, comp_ctx->direct_len);
|
||||
tmpbuf->i += comp_ctx->direct_len;
|
||||
b_add(tmpbuf, comp_ctx->direct_len);
|
||||
comp_ctx->direct_ptr = NULL;
|
||||
comp_ctx->direct_len = 0;
|
||||
comp_ctx->queued = tmpbuf;
|
||||
@ -318,7 +318,7 @@ static int rfc195x_add_data(struct comp_ctx *comp_ctx, const char *in_data, int
|
||||
if (comp_ctx->queued) {
|
||||
/* data already pending */
|
||||
memcpy(b_tail(comp_ctx->queued), in_data, in_len);
|
||||
comp_ctx->queued->i += in_len;
|
||||
b_add(comp_ctx->queued, 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, b_tail(out), in_ptr, in_len, !finish);
|
||||
b_add(out, slz_encode(strm, b_tail(out), in_ptr, in_len, !finish));
|
||||
|
||||
if (finish)
|
||||
out->i += slz_finish(strm, b_tail(out));
|
||||
b_add(out, slz_finish(strm, b_tail(out)));
|
||||
|
||||
out_len = out->i - out_len;
|
||||
|
||||
@ -589,7 +589,7 @@ static int deflate_add_data(struct comp_ctx *comp_ctx, const char *in_data, int
|
||||
return -1;
|
||||
|
||||
/* deflate update the available data out */
|
||||
out->i += out_len - strm->avail_out;
|
||||
b_add(out, out_len - strm->avail_out);
|
||||
|
||||
return in_len - strm->avail_in;
|
||||
}
|
||||
@ -610,7 +610,7 @@ static int deflate_flush_or_finish(struct comp_ctx *comp_ctx, struct buffer *out
|
||||
return -1;
|
||||
|
||||
out_len = b_room(out) - strm->avail_out;
|
||||
out->i += out_len;
|
||||
b_add(out, out_len);
|
||||
|
||||
/* compression limit */
|
||||
if ((global.comp_rate_lim > 0 && (read_freq_ctr(&global.comp_bps_out) > global.comp_rate_lim)) || /* rate */
|
||||
|
@ -212,7 +212,7 @@ comp_http_data(struct stream *s, struct filter *filter, struct http_msg *msg)
|
||||
memcpy(b_tail(tmpbuf)+block, buf->data, len-block);
|
||||
c_rew(chn, *nxt);
|
||||
|
||||
tmpbuf->i += len;
|
||||
b_add(tmpbuf, len);
|
||||
ret = len;
|
||||
}
|
||||
else {
|
||||
@ -770,10 +770,10 @@ http_compression_buffer_end(struct comp_state *st, struct stream *s,
|
||||
if (ib->i > 0) {
|
||||
left = ci_contig_data(chn);
|
||||
memcpy(ob->p + ob->i, ci_head(chn), left);
|
||||
ob->i += left;
|
||||
b_add(ob, left);
|
||||
if (ib->i - left) {
|
||||
memcpy(ob->p + ob->i, ib->data, ib->i - left);
|
||||
ob->i += ib->i - left;
|
||||
b_add(ob, ib->i - left);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2742,7 +2742,7 @@ static int h2_frt_decode_headers(struct h2s *h2s, struct buffer *buf, int count,
|
||||
/* now consume the input data */
|
||||
b_del(h2c->dbuf, h2c->dfl);
|
||||
h2c->st0 = H2_CS_FRAME_H;
|
||||
buf->i += outlen;
|
||||
b_add(buf, outlen);
|
||||
|
||||
/* don't send it before returning data!
|
||||
* FIXME: should we instead try to send it much later, after the
|
||||
@ -3091,7 +3091,7 @@ static size_t h2s_frt_make_resp_headers(struct h2s *h2s, const struct buffer *bu
|
||||
|
||||
/* commit the H2 response */
|
||||
h2c->mbuf->p = b_peek(h2c->mbuf, h2c->mbuf->o + outbuf.len);
|
||||
h2c->mbuf->o += outbuf.len;
|
||||
bo_add(h2c->mbuf, outbuf.len);
|
||||
h2s->flags |= H2_SF_HEADERS_SENT;
|
||||
|
||||
/* for now we don't implemented CONTINUATION, so we wait for a
|
||||
@ -3337,7 +3337,7 @@ static size_t h2s_frt_make_resp_data(struct h2s *h2s, const struct buffer *buf,
|
||||
|
||||
/* commit the H2 response */
|
||||
h2c->mbuf->p = b_peek(h2c->mbuf, h2c->mbuf->o + size + 9);
|
||||
h2c->mbuf->o += size + 9;
|
||||
bo_add(h2c->mbuf, size + 9);
|
||||
|
||||
/* consume incoming H1 response */
|
||||
if (size > 0) {
|
||||
|
@ -294,7 +294,7 @@ static size_t raw_sock_to_buf(struct connection *conn, struct buffer *buf, size_
|
||||
ret = recv(conn->handle.fd, b_tail(buf), try, 0);
|
||||
|
||||
if (ret > 0) {
|
||||
buf->i += ret;
|
||||
b_add(buf, ret);
|
||||
done += ret;
|
||||
if (ret < try) {
|
||||
/* unfortunately, on level-triggered events, POLL_HUP
|
||||
|
@ -5374,7 +5374,7 @@ static size_t ssl_sock_to_buf(struct connection *conn, struct buffer *buf, size_
|
||||
done++;
|
||||
try--;
|
||||
count--;
|
||||
buf->i++;
|
||||
b_add(buf, 1);
|
||||
conn->tmp_early_data = -1;
|
||||
continue;
|
||||
}
|
||||
@ -5421,7 +5421,7 @@ static size_t ssl_sock_to_buf(struct connection *conn, struct buffer *buf, size_
|
||||
goto out_error;
|
||||
}
|
||||
if (ret > 0) {
|
||||
buf->i += ret;
|
||||
b_add(buf, ret);
|
||||
done += ret;
|
||||
count -= ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user