Mercurial > dovecot > core-2.2
changeset 22581:55a7f5a381cd
acl: Cleanup - move code to a new acl_vfile_validity_has_changed()
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Fri, 06 Oct 2017 16:54:20 +0300 |
parents | b88a68d75655 |
children | 954ccfeef2f4 |
files | src/plugins/acl/acl-backend-vfile.c |
diffstat | 1 files changed, 23 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/src/plugins/acl/acl-backend-vfile.c Fri Oct 06 16:44:01 2017 +0300 +++ b/src/plugins/acl/acl-backend-vfile.c Fri Oct 06 16:54:20 2017 +0300 @@ -457,6 +457,28 @@ } static int +acl_vfile_validity_has_changed(struct acl_backend_vfile *backend, + const struct acl_vfile_validity *validity, + const struct stat *st) +{ + if (st->st_mtime == validity->last_mtime && + st->st_size == validity->last_size) { + /* same timestamp, but if it was modified within the + same second we want to refresh it again later (but + do it only after a couple of seconds so we don't + keep re-reading it all the time within those + seconds) */ + time_t cache_secs = backend->cache_secs; + + if (validity->last_read_time != 0 && + (st->st_mtime < validity->last_read_time - cache_secs || + ioloop_time - validity->last_read_time <= cache_secs)) + return FALSE; + } + return TRUE; +} + +static int acl_backend_vfile_refresh(struct acl_object *aclobj, const char *path, struct acl_vfile_validity *validity) { @@ -489,23 +511,7 @@ i_error("stat(%s) failed: %m", path); return -1; } - - if (st.st_mtime == validity->last_mtime && - st.st_size == validity->last_size) { - /* same timestamp, but if it was modified within the - same second we want to refresh it again later (but - do it only after a couple of seconds so we don't - keep re-reading it all the time within those - seconds) */ - time_t cache_secs = backend->cache_secs; - - if (validity->last_read_time != 0 && - (st.st_mtime < validity->last_read_time - cache_secs || - ioloop_time - validity->last_read_time <= cache_secs)) - return 0; - } - - return 1; + return acl_vfile_validity_has_changed(backend, validity, &st) ? 1 : 0; } int acl_backend_vfile_object_get_mtime(struct acl_object *aclobj,