From 0d40c4e83f6fbfea2f494f1f88412d3132ff98bd Mon Sep 17 00:00:00 2001 From: "Neal H. Walfield" Date: Mon, 17 Aug 2015 12:29:15 +0200 Subject: [PATCH] common/iobuf.c: Adjust buffer size of filters in front of temp filters. * common/iobuf.c (iobuf_push_filter2): If the head filter is a temp filter, use IOBUF_BUFFER_SIZE for the new filter. -- Signed-off-by: Neal H. Walfield . --- common/iobuf.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/common/iobuf.c b/common/iobuf.c index 6d85124eb..7d75e33f7 100644 --- a/common/iobuf.c +++ b/common/iobuf.c @@ -1604,8 +1604,21 @@ iobuf_push_filter2 (iobuf_t a, a->filter_ov_owner = 0; a->filter_eof = 0; if (a->use == IOBUF_TEMP) - /* make a write stream from a temp stream */ - a->use = IOBUF_OUTPUT; + /* A TEMP filter buffers any data sent to it; it does not forward + any data down the pipeline. If we add a new filter to the + pipeline, it shouldn't also buffer data. It should send it + downstream to be buffered. Thus, the correct type for a filter + added in front of an IOBUF_TEMP filter is IOBUF_OUPUT, not + IOBUF_TEMP. */ + { + a->use = IOBUF_OUTPUT; + + /* When pipeline is written to, the temp buffer's size is + increased accordingly. We don't need to allocate a 10 MB + buffer for a non-terminal filter. Just use the default + size. */ + a->d.size = IOBUF_BUFFER_SIZE; + } /* The new filter (A) gets a new buffer.