From: Timo Sirainen Date: Mon, 10 Oct 2016 14:19:32 +0000 (+0300) Subject: quota: Don't execute quota_over_script if userdb lookup was over 10 secs ago X-Git-Tag: 2.2.26~163 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ec769b57dc94f7954799af6e5fd0e5b4b309cb28;p=thirdparty%2Fdovecot%2Fcore.git quota: Don't execute quota_over_script if userdb lookup was over 10 secs ago --- diff --git a/src/plugins/quota/quota.c b/src/plugins/quota/quota.c index 05002da445..902277c819 100644 --- a/src/plugins/quota/quota.c +++ b/src/plugins/quota/quota.c @@ -4,6 +4,7 @@ #include "array.h" #include "hash.h" #include "str.h" +#include "ioloop.h" #include "net.h" #include "write-full.h" #include "eacces-error.h" @@ -19,6 +20,11 @@ "Quota exceeded (mailbox for user is full)" #define QUOTA_LIMIT_SET_PATH DICT_PATH_PRIVATE"quota/limit/" +/* How many seconds after the userdb lookup do we still want to execute the + quota_over_script. This applies to quota_over_flag_lazy_check=yes and also + after unhibernating IMAP connections. */ +#define QUOTA_OVER_FLAG_MAX_DELAY_SECS 10 + struct quota_root_iter { struct quota *quota; struct mailbox *box; @@ -1038,6 +1044,17 @@ static void quota_over_flag_check_root(struct quota_root *root) if (root->quota_over_flag_checked) return; + if (root->quota->user->session_create_time + + QUOTA_OVER_FLAG_MAX_DELAY_SECS < ioloop_time) { + /* userdb's quota_over_flag lookup is too old. */ + return; + } + if (root->quota->user->session_restored) { + /* we don't know whether the quota_over_script was executed + before hibernation. just assume that it was, so we don't + unnecessarily call it too often. */ + return; + } root->quota_over_flag_checked = TRUE; quota_over_flag_init_root(root);