dovecot-2.0: zlib: Don't unnecessarily reset istream caches.
dovecot at dovecot.org
dovecot at dovecot.org
Tue May 10 18:24:38 EEST 2011
details: http://hg.dovecot.org/dovecot-2.0/rev/66ec075a49d3
changeset: 12789:66ec075a49d3
user: Timo Sirainen <tss at iki.fi>
date: Tue May 10 18:24:31 2011 +0300
description:
zlib: Don't unnecessarily reset istream caches.
diffstat:
src/plugins/zlib/istream-bzlib.c | 12 ++++++++++++
src/plugins/zlib/istream-zlib.c | 12 ++++++++++++
2 files changed, 24 insertions(+), 0 deletions(-)
diffs (60 lines):
diff -r 15a0687ec9d0 -r 66ec075a49d3 src/plugins/zlib/istream-bzlib.c
--- a/src/plugins/zlib/istream-bzlib.c Tue May 10 18:19:35 2011 +0300
+++ b/src/plugins/zlib/istream-bzlib.c Tue May 10 18:24:31 2011 +0300
@@ -16,6 +16,7 @@
bz_stream zs;
uoff_t eof_offset;
size_t prev_size, high_pos;
+ struct stat last_parent_statbuf;
unsigned int log_errors:1;
unsigned int marked:1;
@@ -300,7 +301,18 @@
static void i_stream_bzlib_sync(struct istream_private *stream)
{
struct bzlib_istream *zstream = (struct bzlib_istream *) stream;
+ const struct stat *st;
+ st = i_stream_stat(stream->parent, FALSE);
+ if (st != NULL) {
+ if (memcmp(&zstream->last_parent_statbuf,
+ st, sizeof(*st)) == 0) {
+ /* a compressed file doesn't change unexpectedly,
+ don't clear our caches unnecessarily */
+ return;
+ }
+ zstream->last_parent_statbuf = *st;
+ }
i_stream_bzlib_reset(zstream);
}
diff -r 15a0687ec9d0 -r 66ec075a49d3 src/plugins/zlib/istream-zlib.c
--- a/src/plugins/zlib/istream-zlib.c Tue May 10 18:19:35 2011 +0300
+++ b/src/plugins/zlib/istream-zlib.c Tue May 10 18:24:31 2011 +0300
@@ -28,6 +28,7 @@
uoff_t eof_offset;
size_t prev_size, high_pos;
uint32_t crc32;
+ struct stat last_parent_statbuf;
unsigned int gz:1;
unsigned int log_errors:1;
@@ -446,7 +447,18 @@
static void i_stream_zlib_sync(struct istream_private *stream)
{
struct zlib_istream *zstream = (struct zlib_istream *) stream;
+ const struct stat *st;
+ st = i_stream_stat(stream->parent, FALSE);
+ if (st != NULL) {
+ if (memcmp(&zstream->last_parent_statbuf,
+ st, sizeof(*st)) == 0) {
+ /* a compressed file doesn't change unexpectedly,
+ don't clear our caches unnecessarily */
+ return;
+ }
+ zstream->last_parent_statbuf = *st;
+ }
i_stream_zlib_reset(zstream);
}
More information about the dovecot-cvs
mailing list