From 2898ad0028a9b0c30df96dd6b68930fd4dc57527 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Fri, 17 Feb 2017 18:56:23 +0200 Subject: [PATCH] lib-storage: Add MAIL_ERROR_LIMIT --- src/doveadm/doveadm-mail.c | 7 ++++--- src/imap/imap-commands-util.c | 3 +++ src/lib-storage/index/dbox-multi/mdbox-map.c | 2 +- src/lib-storage/index/imapc/imapc-storage.c | 2 +- src/lib-storage/mail-error.h | 2 ++ 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/doveadm/doveadm-mail.c b/src/doveadm/doveadm-mail.c index 20dfb6a194..b4557ab389 100644 --- a/src/doveadm/doveadm-mail.c +++ b/src/doveadm/doveadm-mail.c @@ -53,13 +53,12 @@ int doveadm_killed_signo(void) void doveadm_mail_failed_error(struct doveadm_mail_cmd_context *ctx, enum mail_error error) { - int exit_code = 0; + int exit_code = EX_TEMPFAIL; switch (error) { case MAIL_ERROR_NONE: i_unreached(); case MAIL_ERROR_TEMP: - exit_code = EX_TEMPFAIL; break; case MAIL_ERROR_NOTPOSSIBLE: case MAIL_ERROR_EXISTS: @@ -81,7 +80,9 @@ void doveadm_mail_failed_error(struct doveadm_mail_cmd_context *ctx, break; case MAIL_ERROR_EXPUNGED: case MAIL_ERROR_INUSE: - exit_code = EX_TEMPFAIL; + break; + case MAIL_ERROR_LIMIT: + exit_code = DOVEADM_EX_NOTPOSSIBLE; break; } /* tempfail overrides all other exit codes, otherwise use whatever diff --git a/src/imap/imap-commands-util.c b/src/imap/imap-commands-util.c index 6886f4f43f..d724077231 100644 --- a/src/imap/imap-commands-util.c +++ b/src/imap/imap-commands-util.c @@ -169,6 +169,9 @@ imap_get_error_string(struct client_command_context *cmd, case MAIL_ERROR_CONVERSION: case MAIL_ERROR_INVALIDDATA: break; + case MAIL_ERROR_LIMIT: + resp_code = IMAP_RESP_CODE_LIMIT; + break; } if (resp_code == NULL || *error_string == '[') return t_strconcat("NO ", error_string, NULL); diff --git a/src/lib-storage/index/dbox-multi/mdbox-map.c b/src/lib-storage/index/dbox-multi/mdbox-map.c index 59bc749ba4..b597ad2637 100644 --- a/src/lib-storage/index/dbox-multi/mdbox-map.c +++ b/src/lib-storage/index/dbox-multi/mdbox-map.c @@ -674,7 +674,7 @@ int mdbox_map_update_refcount(struct mdbox_map_transaction_context *ctx, /* we're getting close to the 64k limit. fail early to make it less likely that two processes increase the refcount enough times to cross the limit */ - mail_storage_set_error(MAP_STORAGE(map), MAIL_ERROR_NOTPOSSIBLE, + mail_storage_set_error(MAP_STORAGE(map), MAIL_ERROR_LIMIT, t_strdup_printf("Message has been copied too many times (%d + %d)", old_diff, new_diff)); return -1; diff --git a/src/lib-storage/index/imapc/imapc-storage.c b/src/lib-storage/index/imapc/imapc-storage.c index b916bc4440..b2df83daf8 100644 --- a/src/lib-storage/index/imapc/imapc-storage.c +++ b/src/lib-storage/index/imapc/imapc-storage.c @@ -45,7 +45,7 @@ static struct imapc_resp_code_map imapc_resp_code_map[] = { { IMAP_RESP_CODE_SERVERBUG, MAIL_ERROR_TEMP }, /* { IMAP_RESP_CODE_CLIENTBUG, 0 }, */ { IMAP_RESP_CODE_CANNOT, MAIL_ERROR_NOTPOSSIBLE }, - { IMAP_RESP_CODE_LIMIT, MAIL_ERROR_NOTPOSSIBLE }, + { IMAP_RESP_CODE_LIMIT, MAIL_ERROR_LIMIT }, { IMAP_RESP_CODE_OVERQUOTA, MAIL_ERROR_NOQUOTA }, { IMAP_RESP_CODE_ALREADYEXISTS, MAIL_ERROR_EXISTS }, { IMAP_RESP_CODE_NONEXISTENT, MAIL_ERROR_NOTFOUND } diff --git a/src/lib-storage/mail-error.h b/src/lib-storage/mail-error.h index 420f01b662..4b11178869 100644 --- a/src/lib-storage/mail-error.h +++ b/src/lib-storage/mail-error.h @@ -47,6 +47,8 @@ enum mail_error { /* Can't do the requested data conversion because the original data isn't valid. */ MAIL_ERROR_INVALIDDATA, + /* Operation ran against some kind of a limit. */ + MAIL_ERROR_LIMIT, }; /* Convert errno to mail_error and an error string. Returns TRUE if successful,