From f941cf2ef2e383d8bd34de2493dd9c983ab316f7 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Mon, 27 Aug 2012 20:53:34 +0200 Subject: [PATCH] MAJOR: channel: remove the BF_FULL flag This is similar to the recent removal of BF_OUT_EMPTY. This flag was very problematic because it relies on permanently changing information such as the to_forward value, so it had to be updated upon every change to the buffers. Previous patch already got rid of its users. One part of the change is sensible : the flag was also part of BF_MASK_STATIC, which is used by process_session() to rescan all analysers in case the flag's status changes. At first glance, none of the analysers seems to change its mind base on this flag when it is subject to change, so it seems fine not to add variation checks here. Otherwise it's possible that checking the buffer's input and output is more reliable than checking the flag's replacement. --- include/proto/channel.h | 12 +++--------- include/types/channel.h | 8 ++------ src/channel.c | 25 ++----------------------- src/stream_interface.c | 5 ----- 4 files changed, 7 insertions(+), 43 deletions(-) diff --git a/include/proto/channel.h b/include/proto/channel.h index 6d4d3e739..4ba55b9f6 100644 --- a/include/proto/channel.h +++ b/include/proto/channel.h @@ -209,7 +209,6 @@ static inline void buffer_erase(struct channel *buf) buf->buf.i = 0; buf->to_forward = 0; buf->buf.p = buf->buf.data; - buf->flags &= ~BF_FULL; } /* Cut the "tail" of the buffer, which means strip it to the length of unsent @@ -227,7 +226,6 @@ static inline void bi_erase(struct channel *buf) return; buf->buf.i = 0; - buf->flags &= ~BF_FULL; } /* marks the buffer as "shutdown" ASAP for reads */ @@ -320,9 +318,6 @@ static inline void bo_skip(struct channel *buf, int len) if (buffer_len(&buf->buf) == 0) buf->buf.p = buf->buf.data; - if (!channel_full(buf)) - buf->flags &= ~BF_FULL; - /* notify that some data was written to the SI from the buffer */ buf->flags |= BF_WRITE_PARTIAL; } @@ -332,8 +327,8 @@ static inline void bo_skip(struct channel *buf, int len) * closed, -2 is returned. If the block is too large for this buffer, -3 is * returned. If there is not enough room left in the buffer, -1 is returned. * Otherwise the number of bytes copied is returned (0 being a valid number). - * Buffer flags FULL, EMPTY and READ_PARTIAL are updated if some data can be - * transferred. The chunk's length is updated with the number of bytes sent. + * Buffer flag READ_PARTIAL is updated if some data can be transferred. The + * chunk's length is updated with the number of bytes sent. */ static inline int bi_putchk(struct channel *buf, struct chunk *chunk) { @@ -350,8 +345,7 @@ static inline int bi_putchk(struct channel *buf, struct chunk *chunk) * closed, -2 is returned. If the block is too large for this buffer, -3 is * returned. If there is not enough room left in the buffer, -1 is returned. * Otherwise the number of bytes copied is returned (0 being a valid number). - * Buffer flags FULL, EMPTY and READ_PARTIAL are updated if some data can be - * transferred. + * Buffer flag READ_PARTIAL is updated if some data can be transferred. */ static inline int bi_putstr(struct channel *buf, const char *str) { diff --git a/include/types/channel.h b/include/types/channel.h index 67016d107..224d0da7b 100644 --- a/include/types/channel.h +++ b/include/types/channel.h @@ -59,7 +59,7 @@ #define BF_READ_ERROR 0x000008 /* unrecoverable error on producer side */ #define BF_READ_ACTIVITY (BF_READ_NULL|BF_READ_PARTIAL|BF_READ_ERROR) -#define BF_FULL 0x000010 /* channel cannot accept any more data (l >= max len) */ +/* unused: 0x000010 */ #define BF_SHUTR 0x000020 /* producer has already shut down */ #define BF_SHUTR_NOW 0x000040 /* the producer must shut down for reads ASAP */ #define BF_READ_NOEXP 0x000080 /* producer should not expire */ @@ -129,7 +129,7 @@ #define BF_MASK_ANALYSER (BF_READ_ATTACHED|BF_READ_ACTIVITY|BF_READ_TIMEOUT|BF_ANA_TIMEOUT|BF_WRITE_ACTIVITY|BF_WAKE_ONCE) /* Mask for static flags which cause analysers to be woken up when they change */ -#define BF_MASK_STATIC (BF_FULL|BF_SHUTR|BF_SHUTW|BF_SHUTR_NOW|BF_SHUTW_NOW) +#define BF_MASK_STATIC (BF_SHUTR|BF_SHUTW|BF_SHUTR_NOW|BF_SHUTW_NOW) /* Analysers (channel->analysers). @@ -257,10 +257,6 @@ struct channel { global.maxrewrite, then we don't want to fill the buffer with more than ->size - global.maxrewrite + ->to_forward. - Note that this also means that anyone touching ->to_forward must also take - care of updating the BF_FULL flag. For this reason, it's really advised to - use buffer_forward() only. - A buffer may contain up to 5 areas : - the data waiting to be sent. These data are located between ->w and ->w+o ; diff --git a/src/channel.c b/src/channel.c index 2af945af0..ce90147b7 100644 --- a/src/channel.c +++ b/src/channel.c @@ -126,11 +126,6 @@ int bo_inject(struct channel *buf, const char *msg, int len) buf->buf.o += len; buf->buf.p = b_ptr(&buf->buf, len); buf->total += len; - - buf->flags &= ~BF_FULL; - if (channel_full(buf)) - buf->flags |= BF_FULL; - return -1; } @@ -138,8 +133,7 @@ int bo_inject(struct channel *buf, const char *msg, int len) * ->o and to_forward pointers are updated. If the buffer's input is * closed, -2 is returned. If there is not enough room left in the buffer, -1 * is returned. Otherwise the number of bytes copied is returned (1). Buffer - * flags FULL, EMPTY and READ_PARTIAL are updated if some data can be - * transferred. + * flag READ_PARTIAL is updated if some data can be transferred. */ int bi_putchr(struct channel *buf, char c) { @@ -152,8 +146,6 @@ int bi_putchr(struct channel *buf, char c) *bi_end(&buf->buf) = c; buf->buf.i++; - if (channel_full(buf)) - buf->flags |= BF_FULL; buf->flags |= BF_READ_PARTIAL; if (buf->to_forward >= 1) { @@ -171,8 +163,7 @@ int bi_putchr(struct channel *buf, char c) * closed, -2 is returned. If the block is too large for this buffer, -3 is * returned. If there is not enough room left in the buffer, -1 is returned. * Otherwise the number of bytes copied is returned (0 being a valid number). - * Buffer flags FULL, EMPTY and READ_PARTIAL are updated if some data can be - * transferred. + * Buffer flag READ_PARTIAL is updated if some data can be transferred. */ int bi_putblk(struct channel *buf, const char *blk, int len) { @@ -214,10 +205,6 @@ int bi_putblk(struct channel *buf, const char *blk, int len) b_adv(&buf->buf, fwd); } - buf->flags &= ~BF_FULL; - if (channel_full(buf)) - buf->flags |= BF_FULL; - /* notify that some data was read from the SI into the buffer */ buf->flags |= BF_READ_PARTIAL; return len; @@ -343,11 +330,8 @@ int buffer_replace2(struct channel *b, char *pos, char *end, const char *str, in b->buf.i += delta; - b->flags &= ~BF_FULL; if (buffer_len(&b->buf) == 0) b->buf.p = b->buf.data; - if (channel_full(b)) - b->flags |= BF_FULL; return delta; } @@ -382,11 +366,6 @@ int buffer_insert_line2(struct channel *b, char *pos, const char *str, int len) } b->buf.i += delta; - - b->flags &= ~BF_FULL; - if (channel_full(b)) - b->flags |= BF_FULL; - return delta; } diff --git a/src/stream_interface.c b/src/stream_interface.c index aa7716a70..4f31343c3 100644 --- a/src/stream_interface.c +++ b/src/stream_interface.c @@ -729,9 +729,6 @@ static int si_conn_send_loop(struct connection *conn) b->flags |= BF_WRITE_PARTIAL; - if (likely(!channel_full(b))) - b->flags &= ~BF_FULL; - if (!b->buf.o) { /* Always clear both flags once everything has been sent, they're one-shot */ b->flags &= ~(BF_EXPECT_MORE | BF_SEND_DONTWAIT); @@ -1054,7 +1051,6 @@ void si_conn_recv_cb(struct connection *conn) max = bi_avail(b); if (!max) { - b->flags |= BF_FULL; conn->flags |= CO_FL_WAIT_ROOM; break; } @@ -1115,7 +1111,6 @@ void si_conn_recv_cb(struct connection *conn) b->xfer_large = 0; } - b->flags |= BF_FULL; si->flags |= SI_FL_WAIT_ROOM; break; }