changeset 4289:58a7882ba128 HEAD

Don't check ACL file's timestamp changes more often than once in a second.
author Timo Sirainen <timo.sirainen@movial.fi>
date Tue, 30 May 2006 15:20:30 +0300
parents 1cb59399b395
children 823f6515ffdc
files src/plugins/acl/acl-backend-vfile.c src/plugins/acl/acl-cache.c src/plugins/acl/acl-cache.h
diffstat 3 files changed, 16 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/acl/acl-backend-vfile.c	Tue May 30 14:51:53 2006 +0300
+++ b/src/plugins/acl/acl-backend-vfile.c	Tue May 30 15:20:30 2006 +0300
@@ -15,10 +15,17 @@
 
 #define ACL_FILENAME "dovecot-acl"
 
+/* Minimum time between stat()ing the ACL file to see if its timestamp has
+   changed. */
+#define ACL_VALIDITY_SECS 1
+/* Time difference to allow between this system's time and file server's time */
 #define ACL_SYNC_SECS 1
+
 #define ACL_ESTALE_RETRY_COUNT NFS_ESTALE_RETRY_COUNT
 
 struct acl_vfile_validity {
+	time_t last_check;
+
 	time_t last_read_time;
 	time_t last_mtime;
 	off_t last_size;
@@ -341,15 +348,17 @@
 
 static int
 acl_backend_vfile_refresh(struct acl_object *aclobj, const char *path,
-			  const struct acl_vfile_validity *validity)
+			  struct acl_vfile_validity *validity)
 {
 	struct stat st;
 
 	if (validity == NULL)
 		return 1;
-	if (path == NULL)
+	if (path == NULL ||
+	    validity->last_check + ACL_VALIDITY_SECS > ioloop_time)
 		return 0;
 
+	validity->last_check = ioloop_time;
 	if (stat(path, &st) < 0) {
 		if (errno == ENOENT) {
 			/* if the file used to exist, we have to re-read it */
@@ -378,7 +387,7 @@
 static int acl_backend_vfile_object_refresh_cache(struct acl_object *_aclobj)
 {
 	struct acl_object_vfile *aclobj = (struct acl_object_vfile *)_aclobj;
-	const struct acl_backend_vfile_validity *old_validity;
+	struct acl_backend_vfile_validity *old_validity;
 	struct acl_backend_vfile_validity validity;
 	int ret;
 
--- a/src/plugins/acl/acl-cache.c	Tue May 30 14:51:53 2006 +0300
+++ b/src/plugins/acl/acl-cache.c	Tue May 30 15:20:30 2006 +0300
@@ -329,8 +329,7 @@
 	} 
 }
 
-const void *acl_cache_get_validity(struct acl_cache *cache,
-				   const char *objname)
+void *acl_cache_get_validity(struct acl_cache *cache, const char *objname)
 {
 	struct acl_object_cache *obj_cache;
 
--- a/src/plugins/acl/acl-cache.h	Tue May 30 14:51:53 2006 +0300
+++ b/src/plugins/acl/acl-cache.h	Tue May 30 15:20:30 2006 +0300
@@ -35,12 +35,11 @@
 /* Update object ACLs. */
 void acl_cache_update(struct acl_cache *cache, const char *objname,
 		      const struct acl_rights *rights);
-/* Update ACL object validity. */
+/* Return ACL object validity, or NULL if object doesn't exit. */
+void *acl_cache_get_validity(struct acl_cache *cache, const char *objname);
+/* Update ACL object validity, creating the object if needed. */
 void acl_cache_set_validity(struct acl_cache *cache, const char *objname,
 			    const void *validity);
-/* Return ACL object validity. */
-const void *acl_cache_get_validity(struct acl_cache *cache,
-				   const char *objname);
 
 /* Returns all the right names currently created. The returned pointer may
    change after calling acl_cache_update(). */