From fb1927dad988a34040afe4a1e51a5dbe3c085c8f Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Tue, 13 Oct 2015 13:44:48 +0300 Subject: [PATCH] auth: passwd-file now stat()s the file max once per second. It's quite unnecessary to do it more often. --- src/auth/db-passwd-file.c | 5 +++++ src/auth/db-passwd-file.h | 1 + 2 files changed, 6 insertions(+) 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; -- 2.47.3