dovecot-2.2: istream-chain: Fixed handling small streams that ge...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Apr 4 21:19:07 EEST 2013
details: http://hg.dovecot.org/dovecot-2.2/rev/096ad7cd6e9e
changeset: 16168:096ad7cd6e9e
user: Timo Sirainen <tss at iki.fi>
date: Thu Apr 04 21:18:28 2013 +0300
description:
istream-chain: Fixed handling small streams that get merged into same buffer.
diffstat:
src/lib/istream-chain.c | 27 +++++++++++++++------------
1 files changed, 15 insertions(+), 12 deletions(-)
diffs (40 lines):
diff -r 2294f815a4f0 -r 096ad7cd6e9e src/lib/istream-chain.c
--- a/src/lib/istream-chain.c Thu Apr 04 20:32:28 2013 +0300
+++ b/src/lib/istream-chain.c Thu Apr 04 21:18:28 2013 +0300
@@ -118,21 +118,24 @@
if (link != NULL && link->stream != NULL)
i_stream_seek(link->stream, 0);
- /* we already verified that the data size is less than the
- maximum buffer size */
- cstream->istream.pos = 0;
- if (data_size > 0) {
- if (!i_stream_try_alloc(&cstream->istream, data_size, &size))
- i_unreached();
- i_assert(size >= data_size);
+ if (cstream->istream.buffer == cstream->istream.w_buffer) {
+ /* we've already buffered the prev_input */
+ } else {
+ /* we already verified that the data size is less than the
+ maximum buffer size */
+ cstream->istream.pos = 0;
+ if (data_size > 0) {
+ if (!i_stream_try_alloc(&cstream->istream, data_size, &size))
+ i_unreached();
+ i_assert(size >= data_size);
+ }
+ memcpy(cstream->istream.w_buffer, data, data_size);
+ cstream->istream.skip = 0;
+ cstream->istream.pos = data_size;
+ cstream->prev_stream_left = data_size;
}
-
- memcpy(cstream->istream.w_buffer, data, data_size);
i_stream_skip(prev_input, data_size);
i_stream_unref(&prev_input);
- cstream->istream.skip = 0;
- cstream->istream.pos = data_size;
- cstream->prev_stream_left = data_size;
}
static ssize_t i_stream_chain_read(struct istream_private *stream)
More information about the dovecot-cvs
mailing list