From: Martti Rannanjärvi Date: Thu, 2 Nov 2017 10:04:46 +0000 (+0200) Subject: quota: Add QUOTA_ALLOC_RESULT_BACKGROUND_CALC enum value X-Git-Tag: 2.3.0.rc1~482 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b14f93ea4f7e9b78e5adbabcc78bd2f63d2bcd36;p=thirdparty%2Fdovecot%2Fcore.git quota: Add QUOTA_ALLOC_RESULT_BACKGROUND_CALC enum value --- diff --git a/src/plugins/quota/quota-status.c b/src/plugins/quota/quota-status.c index 1b227339ff..3a466de95e 100644 --- a/src/plugins/quota/quota-status.c +++ b/src/plugins/quota/quota-status.c @@ -128,6 +128,7 @@ static void client_handle_request(struct quota_client *client) value = t_strdup_printf("554 5.2.2 %s", error); break; case QUOTA_ALLOC_RESULT_TEMPFAIL: + case QUOTA_ALLOC_RESULT_BACKGROUND_CALC: ret = -1; break; } diff --git a/src/plugins/quota/quota-storage.c b/src/plugins/quota/quota-storage.c index 41cff34b34..1affc1f7fa 100644 --- a/src/plugins/quota/quota-storage.c +++ b/src/plugins/quota/quota-storage.c @@ -61,6 +61,7 @@ static void quota_set_storage_error(struct quota_transaction_context *qt, mail_storage_set_error(storage, MAIL_ERROR_NOQUOTA, errstr); break; case QUOTA_ALLOC_RESULT_TEMPFAIL: + case QUOTA_ALLOC_RESULT_BACKGROUND_CALC: mail_storage_set_critical(storage, "quota: %s", internal_err); break; case QUOTA_ALLOC_RESULT_OK: @@ -261,6 +262,10 @@ static int quota_check(struct mail_save_context *ctx, struct mailbox *src_box) /* Log the error, but allow saving anyway. */ i_error("quota: Failed to check if user is under quota: %s - saving mail anyway", error); return 0; + case QUOTA_ALLOC_RESULT_BACKGROUND_CALC: + /* Could not determine if there is enough space due to ongoing + background quota calculation, allow saving anyway. */ + return 0; default: quota_set_storage_error(qt, t->box->storage, ret, error); return -1; @@ -324,6 +329,11 @@ quota_save_begin(struct mail_save_context *ctx, struct istream *input) /* Log the error, but allow saving anyway. */ i_error("quota: Failed to check if user is under quota: %s - saving mail anyway", error); break; + case QUOTA_ALLOC_RESULT_BACKGROUND_CALC: + /* Could not determine if there is enough space due to + * ongoing background quota calculation, allow saving + * anyway. */ + break; default: quota_set_storage_error(qt, t->box->storage, qret, error); return -1; diff --git a/src/plugins/quota/quota.c b/src/plugins/quota/quota.c index 9011101f51..ebfa710e29 100644 --- a/src/plugins/quota/quota.c +++ b/src/plugins/quota/quota.c @@ -283,6 +283,8 @@ const char *quota_alloc_result_errstr(enum quota_alloc_result res, switch (res) { case QUOTA_ALLOC_RESULT_OK: return "OK"; + case QUOTA_ALLOC_RESULT_BACKGROUND_CALC: + return "Blocked by an ongoing background quota calculation"; case QUOTA_ALLOC_RESULT_TEMPFAIL: return "Internal quota calculation error"; case QUOTA_ALLOC_RESULT_OVER_MAXSIZE: diff --git a/src/plugins/quota/quota.h b/src/plugins/quota/quota.h index fcb0dcb526..cd3a251b27 100644 --- a/src/plugins/quota/quota.h +++ b/src/plugins/quota/quota.h @@ -47,6 +47,8 @@ enum quota_alloc_result { QUOTA_ALLOC_RESULT_OVER_QUOTA, /* Mail size is larger than even the maximum allowed quota. */ QUOTA_ALLOC_RESULT_OVER_QUOTA_LIMIT, + /* Blocked by ongoing background quota calculation. */ + QUOTA_ALLOC_RESULT_BACKGROUND_CALC, }; /* Anything <= QUOTA_GET_RESULT_INTERNAL_ERROR is an error. */