mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-02-17 11:06:54 +00:00
MEDIUM: buffers: move "output" from struct buffer to struct channel
Since we never access this field directly anymore, but only through the channel's wrappers, it can now move to the channel. The buffers are now completely free from the distinction between input and output data.
This commit is contained in:
parent
892f1dbe4f
commit
08afac0fd7
@ -35,7 +35,6 @@ struct buffer {
|
||||
size_t head; /* start offset of remaining data relative to area */
|
||||
size_t len; /* length of data after head */
|
||||
size_t size; /* buffer size in bytes */
|
||||
size_t output; /* TEMPORARY: part of <len> which is to be forwarded */
|
||||
char area[0]; /* <size> bytes of stored data */
|
||||
};
|
||||
|
||||
@ -367,7 +366,6 @@ static inline void b_reset(struct buffer *b)
|
||||
{
|
||||
b->head = 0;
|
||||
b->len = 0;
|
||||
b->output = 0;
|
||||
}
|
||||
|
||||
/* b_sub() : decreases the buffer length by <count> */
|
||||
|
@ -135,7 +135,6 @@ static inline void bo_putchr(struct buffer *b, char c)
|
||||
return;
|
||||
*b_tail(b) = c;
|
||||
b->len++;
|
||||
b->output++;
|
||||
}
|
||||
|
||||
/* Tries to append block <blk> at the end of buffer <b>. Supports wrapping.
|
||||
@ -161,7 +160,6 @@ static inline unsigned int bo_putblk(struct buffer *b, const char *blk, unsigned
|
||||
memcpy(b_tail(b), blk + half, len - half);
|
||||
b->len += len - half;
|
||||
}
|
||||
b->output += len;
|
||||
return len;
|
||||
}
|
||||
|
||||
@ -470,7 +468,6 @@ static inline int bo_istput(struct buffer *b, const struct ist ist)
|
||||
|
||||
p = b_tail(b);
|
||||
b->len += r.len;
|
||||
b->output += r.len;
|
||||
while (r.len--) {
|
||||
*p++ = *r.ptr++;
|
||||
if (unlikely(p == end))
|
||||
|
@ -128,7 +128,7 @@ static inline size_t c_full(const struct channel *c)
|
||||
/* co_data() : returns the amount of output data in the channel's buffer */
|
||||
static inline size_t co_data(const struct channel *c)
|
||||
{
|
||||
return c->buf->output;
|
||||
return c->output;
|
||||
}
|
||||
|
||||
/* ci_data() : returns the amount of input data in the channel's buffer */
|
||||
@ -170,7 +170,7 @@ static inline char *c_ptr(const struct channel *c, ssize_t ofs)
|
||||
*/
|
||||
static inline void c_adv(struct channel *c, size_t adv)
|
||||
{
|
||||
c->buf->output += adv;
|
||||
c->output += adv;
|
||||
}
|
||||
|
||||
/* c_rew() : rewinds the channel's buffer by <adv> bytes, which means that the
|
||||
@ -180,7 +180,7 @@ static inline void c_adv(struct channel *c, size_t adv)
|
||||
*/
|
||||
static inline void c_rew(struct channel *c, size_t adv)
|
||||
{
|
||||
c->buf->output -= adv;
|
||||
c->output -= adv;
|
||||
}
|
||||
|
||||
/* c_realign_if_empty() : realign the channel's buffer if it's empty */
|
||||
@ -192,8 +192,8 @@ static inline void c_realign_if_empty(struct channel *chn)
|
||||
/* Sets the amount of output for the channel */
|
||||
static inline void co_set_data(struct channel *c, size_t output)
|
||||
{
|
||||
c->buf->len += output - c->buf->output;
|
||||
c->buf->output = output;
|
||||
c->buf->len += output - c->output;
|
||||
c->output = output;
|
||||
}
|
||||
|
||||
|
||||
@ -324,6 +324,7 @@ static inline void channel_init(struct channel *chn)
|
||||
chn->pipe = NULL;
|
||||
chn->analysers = 0;
|
||||
chn->flags = 0;
|
||||
chn->output = 0;
|
||||
}
|
||||
|
||||
/* Schedule up to <bytes> more bytes to be forwarded via the channel without
|
||||
@ -767,7 +768,7 @@ static inline void channel_slow_realign(struct channel *chn, char *swap)
|
||||
static inline void co_skip(struct channel *chn, int len)
|
||||
{
|
||||
b_del(chn->buf, len);
|
||||
chn->buf->output -= len;
|
||||
chn->output -= len;
|
||||
c_realign_if_empty(chn);
|
||||
|
||||
/* notify that some data was written to the SI from the buffer */
|
||||
|
@ -189,6 +189,7 @@ struct channel {
|
||||
unsigned int analysers; /* bit field indicating what to do on the channel */
|
||||
struct buffer *buf; /* buffer attached to the channel, always present but may move */
|
||||
struct pipe *pipe; /* non-NULL only when data present */
|
||||
size_t output; /* part of buffer which is to be forwarded */
|
||||
unsigned int to_forward; /* number of bytes to forward after out without a wake-up */
|
||||
unsigned short last_read; /* 16 lower bits of last read date (max pause=65s) */
|
||||
unsigned char xfer_large; /* number of consecutive large xfers */
|
||||
|
@ -784,8 +784,8 @@ http_compression_buffer_end(struct comp_state *st, struct stream *s,
|
||||
/* swap the buffers */
|
||||
*out = chn->buf;
|
||||
chn->buf = ob;
|
||||
tmp_out = chn->buf->output;
|
||||
chn->buf->output = *buf_out;
|
||||
tmp_out = chn->output;
|
||||
chn->output = *buf_out;
|
||||
*buf_out = tmp_out;
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user