dovecot-1.2: Added i_stream_set_init_buffer_size().
dovecot at dovecot.org
dovecot at dovecot.org
Thu Aug 13 19:23:02 EEST 2009
details: http://hg.dovecot.org/dovecot-1.2/rev/70593ef74836
changeset: 9315:70593ef74836
user: Timo Sirainen <tss at iki.fi>
date: Thu Aug 13 12:22:45 2009 -0400
description:
Added i_stream_set_init_buffer_size().
diffstat:
3 files changed, 14 insertions(+), 3 deletions(-)
src/lib/istream-internal.h | 2 +-
src/lib/istream.c | 11 +++++++++--
src/lib/istream.h | 4 ++++
diffs (61 lines):
diff -r 68c1d3ab515d -r 70593ef74836 src/lib/istream-internal.h
--- a/src/lib/istream-internal.h Wed Aug 12 18:12:59 2009 -0400
+++ b/src/lib/istream-internal.h Thu Aug 13 12:22:45 2009 -0400
@@ -27,7 +27,7 @@ struct istream_private {
const unsigned char *buffer;
unsigned char *w_buffer; /* may be NULL */
- size_t buffer_size, max_buffer_size;
+ size_t buffer_size, max_buffer_size, init_buffer_size;
size_t skip, pos;
struct istream *parent; /* for filter streams */
diff -r 68c1d3ab515d -r 70593ef74836 src/lib/istream.c
--- a/src/lib/istream.c Wed Aug 12 18:12:59 2009 -0400
+++ b/src/lib/istream.c Thu Aug 13 12:22:45 2009 -0400
@@ -52,6 +52,11 @@ void i_stream_close(struct istream *stre
if (stream->stream_errno == 0)
stream->stream_errno = ENOENT;
+}
+
+void i_stream_set_init_buffer_size(struct istream *stream, size_t size)
+{
+ stream->real_stream->init_buffer_size = size;
}
void i_stream_set_max_buffer_size(struct istream *stream, size_t max_size)
@@ -399,8 +404,8 @@ void i_stream_grow_buffer(struct istream
old_size = stream->buffer_size;
stream->buffer_size = stream->pos + bytes;
- if (stream->buffer_size <= I_STREAM_MIN_SIZE)
- stream->buffer_size = I_STREAM_MIN_SIZE;
+ if (stream->buffer_size <= stream->init_buffer_size)
+ stream->buffer_size = stream->init_buffer_size;
else
stream->buffer_size = nearest_power(stream->buffer_size);
@@ -481,6 +486,8 @@ i_stream_create(struct istream_private *
_stream->iostream.set_max_buffer_size =
i_stream_default_set_max_buffer_size;
}
+ if (_stream->init_buffer_size == 0)
+ _stream->init_buffer_size = I_STREAM_MIN_SIZE;
memset(&_stream->statbuf, 0, sizeof(_stream->statbuf));
_stream->statbuf.st_size = -1;
diff -r 68c1d3ab515d -r 70593ef74836 src/lib/istream.h
--- a/src/lib/istream.h Wed Aug 12 18:12:59 2009 -0400
+++ b/src/lib/istream.h Thu Aug 13 12:22:45 2009 -0400
@@ -55,6 +55,10 @@ void i_stream_close(struct istream *stre
modified, flush any cached data. */
void i_stream_sync(struct istream *stream);
+/* Change the initial size for stream's input buffer. This basically just
+ grows the read buffer size from the default. This function has no effect
+ unless it's called before reading anything. */
+void i_stream_set_init_buffer_size(struct istream *stream, size_t size);
/* Change the maximum size for stream's input buffer to grow. Useful only
for buffered streams (currently only file). */
void i_stream_set_max_buffer_size(struct istream *stream, size_t max_size);
More information about the dovecot-cvs
mailing list