dovecot-1.2: acl: After updating ACLs, try to avoid re-reading t...
dovecot at dovecot.org
dovecot at dovecot.org
Sun Nov 16 14:15:16 EET 2008
details: http://hg.dovecot.org/dovecot-1.2/rev/6d97abf20724
changeset: 8422:6d97abf20724
user: Timo Sirainen <tss at iki.fi>
date: Sun Nov 16 14:15:13 2008 +0200
description:
acl: After updating ACLs, try to avoid re-reading the ACLs on next access.
diffstat:
1 file changed, 25 insertions(+), 3 deletions(-)
src/plugins/acl/acl-backend-vfile.c | 28 +++++++++++++++++++++++++---
diffs (50 lines):
diff -r 2df1b964d32a -r 6d97abf20724 src/plugins/acl/acl-backend-vfile.c
--- a/src/plugins/acl/acl-backend-vfile.c Sun Nov 16 14:06:15 2008 +0200
+++ b/src/plugins/acl/acl-backend-vfile.c Sun Nov 16 14:15:13 2008 +0200
@@ -1068,6 +1068,24 @@ acl_backend_vfile_update_write(struct ac
return ret;
}
+static void acl_backend_vfile_update_cache(struct acl_object *_aclobj, int fd)
+{
+ struct acl_backend_vfile_validity *validity;
+ struct stat st;
+
+ if (fstat(fd, &st) < 0) {
+ /* we'll just recalculate or fail it later */
+ acl_cache_flush(_aclobj->backend->cache, _aclobj->name);
+ return;
+ }
+
+ validity = acl_cache_get_validity(_aclobj->backend->cache,
+ _aclobj->name);
+ validity->local_validity.last_read_time = ioloop_time;
+ validity->local_validity.last_mtime = st.st_mtime;
+ validity->local_validity.last_size = st.st_size;
+}
+
static int
acl_backend_vfile_object_update(struct acl_object *_aclobj,
const struct acl_rights_update *update)
@@ -1097,14 +1115,18 @@ acl_backend_vfile_object_update(struct a
file_dotlock_delete(&dotlock);
return 0;
} else {
- acl_cache_flush(_aclobj->backend->cache, _aclobj->name);
-
path = file_dotlock_get_lock_path(dotlock);
if (acl_backend_vfile_update_write(aclobj, fd, path) < 0) {
file_dotlock_delete(&dotlock);
+ acl_cache_flush(_aclobj->backend->cache, _aclobj->name);
return -1;
}
- return file_dotlock_replace(&dotlock, 0);
+ acl_backend_vfile_update_cache(_aclobj, fd);
+ if (file_dotlock_replace(&dotlock, 0) < 0) {
+ acl_cache_flush(_aclobj->backend->cache, _aclobj->name);
+ return -1;
+ }
+ return 0;
}
}
More information about the dovecot-cvs
mailing list