From: Timo Sirainen Date: Tue, 13 Oct 2015 10:44:48 +0000 (+0300) Subject: auth: passwd-file now stat()s the file max once per second. X-Git-Tag: 2.2.20.rc1~156 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fb1927dad988a34040afe4a1e51a5dbe3c085c8f;p=thirdparty%2Fdovecot%2Fcore.git auth: passwd-file now stat()s the file max once per second. It's quite unnecessary to do it more often. --- diff --git a/src/auth/db-passwd-file.c b/src/auth/db-passwd-file.c index 30e604d58b..8ebfaca75e 100644 --- a/src/auth/db-passwd-file.c +++ b/src/auth/db-passwd-file.c @@ -13,6 +13,7 @@ #include "hash.h" #include "str.h" #include "eacces-error.h" +#include "ioloop.h" #include #include @@ -261,6 +262,10 @@ static int passwd_file_sync(struct auth_request *request, struct stat st; const char *error; + if (pw->last_sync_time == ioloop_time) + return 0; + pw->last_sync_time = ioloop_time; + if (stat(pw->path, &st) < 0) { /* with variables don't give hard errors, or errors about nonexistent files */ diff --git a/src/auth/db-passwd-file.h b/src/auth/db-passwd-file.h index 54e1ee24af..a137ee17e1 100644 --- a/src/auth/db-passwd-file.h +++ b/src/auth/db-passwd-file.h @@ -20,6 +20,7 @@ struct passwd_file { pool_t pool; int refcount; + time_t last_sync_time; char *path; time_t stamp; off_t size;