]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: buffers: move "output" from struct buffer to struct channel
authorOlivier Houchard <ohouchard@haproxy.com>
Fri, 22 Jun 2018 17:26:39 +0000 (19:26 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 19 Jul 2018 14:23:43 +0000 (16:23 +0200)
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.

include/common/buf.h
include/common/buffer.h
include/proto/channel.h
include/types/channel.h
src/flt_http_comp.c

index e028f90c844018346ef1aacbb49484c6b6523caf..c38d65d85d2b1102e90a9142c91bd3f668469dcf 100644 (file)
@@ -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> */
index fde7b03f29dac08958e15a494dcd1808272ebd66..018b19ec30680e6ca0089898f968b389d3347708 100644 (file)
@@ -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))
index 6241237996a0870f3db29a1eb3b7a94d8dadaa9f..b2efae843b50d1f2a7fd8cb065b70667ce9ccf26 100644 (file)
@@ -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 */
index c483399fa67231b7d7f1ac69582bbe2db224ed75..5205bd6f792f72bb42497a31fb0141e460e4aba6 100644 (file)
@@ -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 */
index 2c15d795d9fbdf977530c90aa1b717fac933f1aa..f54feb2b6f42339deeacb31bab2d94dcd0b52ceb 100644 (file)
@@ -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;