dovecot: Don't re-read maildirsize if it hasn't changed.
dovecot at dovecot.org
dovecot at dovecot.org
Sun Jan 20 08:55:00 EET 2008
details: http://hg.dovecot.org/dovecot/rev/9841a8563116
changeset: 7173:9841a8563116
user: Timo Sirainen <tss at iki.fi>
date: Sun Jan 20 08:54:57 2008 +0200
description:
Don't re-read maildirsize if it hasn't changed.
diffstat:
1 file changed, 24 insertions(+)
src/plugins/quota/quota-maildir.c | 24 ++++++++++++++++++++++++
diffs (39 lines):
diff -r 097fe25ab218 -r 9841a8563116 src/plugins/quota/quota-maildir.c
--- a/src/plugins/quota/quota-maildir.c Sun Jan 20 08:49:36 2008 +0200
+++ b/src/plugins/quota/quota-maildir.c Sun Jan 20 08:54:57 2008 +0200
@@ -460,11 +460,35 @@ static int maildirsize_open(struct maild
return 1;
}
+static bool maildirsize_has_changed(struct maildir_quota_root *root)
+{
+ struct stat st1, st2;
+
+ if (dotlock_settings.nfs_flush) {
+ nfs_flush_file_handle_cache(root->maildirsize_path);
+ nfs_flush_attr_cache_unlocked(root->maildirsize_path);
+ }
+
+ if (root->fd == -1)
+ return TRUE;
+
+ if (stat(root->maildirsize_path, &st1) < 0)
+ return TRUE;
+ if (fstat(root->fd, &st2) < 0)
+ return TRUE;
+
+ return st1.st_size != st2.st_size || st1.st_ino != st2.st_ino ||
+ !CMP_DEV_T(st1.st_dev, st2.st_dev);
+}
+
static int maildirsize_read(struct maildir_quota_root *root)
{
char buf[5120+1];
unsigned int i, size;
int ret;
+
+ if (!maildirsize_has_changed(root))
+ return 1;
if ((ret = maildirsize_open(root)) <= 0)
return ret;
More information about the dovecot-cvs
mailing list