]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: passwd-file now stat()s the file max once per second.
authorTimo Sirainen <tss@iki.fi>
Tue, 13 Oct 2015 10:44:48 +0000 (13:44 +0300)
committerTimo Sirainen <tss@iki.fi>
Tue, 13 Oct 2015 10:44:48 +0000 (13:44 +0300)
It's quite unnecessary to do it more often.

src/auth/db-passwd-file.c
src/auth/db-passwd-file.h

index 30e604d58b4f71a6d085a824051caea1ccc504a1..8ebfaca75e4cf86586473bdf689658317bb5cb44 100644 (file)
@@ -13,6 +13,7 @@
 #include "hash.h"
 #include "str.h"
 #include "eacces-error.h"
+#include "ioloop.h"
 
 #include <unistd.h>
 #include <fcntl.h>
@@ -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 */
index 54e1ee24af5d086e042d3abf2f5a6c9c9fd71106..a137ee17e166b3d4d1c18d1d32058187f3e8a1ba 100644 (file)
@@ -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;