mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-02-07 22:12:08 +00:00
MINOR: buffer: reset a buffer in b_reset() and not channel_init()
We'll soon need to be able to switch buffers without touching the channel, so let's move buffer initialization out of channel_init(). We had the same in compressoin.c.
This commit is contained in:
parent
3dd6a25323
commit
474cf54a97
@ -387,6 +387,14 @@ static inline void bo_putchk(struct buffer *b, const struct chunk *chk)
|
||||
return bo_putblk(b, chk->str, chk->len);
|
||||
}
|
||||
|
||||
/* Resets a buffer. The size is not touched. */
|
||||
static inline void b_reset(struct buffer *buf)
|
||||
{
|
||||
buf->o = 0;
|
||||
buf->i = 0;
|
||||
buf->p = buf->data;
|
||||
}
|
||||
|
||||
#endif /* _COMMON_BUFFER_H */
|
||||
|
||||
/*
|
||||
|
@ -51,9 +51,6 @@ int bo_getblk(struct channel *chn, char *blk, int len, int offset);
|
||||
/* Initialize all fields in the channel. */
|
||||
static inline void channel_init(struct channel *chn)
|
||||
{
|
||||
chn->buf->o = 0;
|
||||
chn->buf->i = 0;
|
||||
chn->buf->p = chn->buf->data;
|
||||
chn->to_forward = 0;
|
||||
chn->last_read = now_ms;
|
||||
chn->xfer_small = chn->xfer_large = 0;
|
||||
@ -185,10 +182,8 @@ static inline void channel_check_timeouts(struct channel *chn)
|
||||
*/
|
||||
static inline void channel_erase(struct channel *chn)
|
||||
{
|
||||
chn->buf->o = 0;
|
||||
chn->buf->i = 0;
|
||||
chn->to_forward = 0;
|
||||
chn->buf->p = chn->buf->data;
|
||||
b_reset(chn->buf);
|
||||
}
|
||||
|
||||
/* marks the channel as "shutdown" ASAP for reads */
|
||||
|
@ -139,9 +139,7 @@ int http_compression_buffer_init(struct session *s, struct buffer *in, struct bu
|
||||
*/
|
||||
|
||||
out->size = global.tune.bufsize;
|
||||
out->i = 0;
|
||||
out->o = 0;
|
||||
out->p = out->data;
|
||||
b_reset(out);
|
||||
|
||||
if (in->o > 0) {
|
||||
left = in->o - bo_contig_data(in);
|
||||
|
@ -1241,6 +1241,7 @@ static struct session *peer_session_create(struct peer *peer, struct peer_sessio
|
||||
goto out_fail_req_buf; /* no memory */
|
||||
|
||||
s->req->buf->size = global.tune.bufsize;
|
||||
b_reset(s->req->buf);
|
||||
channel_init(s->req);
|
||||
s->req->prod = &s->si[0];
|
||||
s->req->cons = &s->si[1];
|
||||
@ -1267,6 +1268,7 @@ static struct session *peer_session_create(struct peer *peer, struct peer_sessio
|
||||
goto out_fail_rep_buf; /* no memory */
|
||||
|
||||
s->rep->buf->size = global.tune.bufsize;
|
||||
b_reset(s->rep->buf);
|
||||
channel_init(s->rep);
|
||||
s->rep->prod = &s->si[1];
|
||||
s->rep->cons = &s->si[0];
|
||||
|
@ -488,6 +488,7 @@ int session_complete(struct session *s)
|
||||
|
||||
/* initialize the request buffer */
|
||||
s->req->buf->size = global.tune.bufsize;
|
||||
b_reset(s->req->buf);
|
||||
channel_init(s->req);
|
||||
s->req->prod = &s->si[0];
|
||||
s->req->cons = &s->si[1];
|
||||
@ -505,6 +506,7 @@ int session_complete(struct session *s)
|
||||
|
||||
/* initialize response buffer */
|
||||
s->rep->buf->size = global.tune.bufsize;
|
||||
b_reset(s->rep->buf);
|
||||
channel_init(s->rep);
|
||||
s->rep->prod = &s->si[1];
|
||||
s->rep->cons = &s->si[0];
|
||||
|
Loading…
Reference in New Issue
Block a user