Skip to content

Commit

Permalink
lib-storage: Add MAIL_ERROR_LIMIT
Browse files Browse the repository at this point in the history
  • Loading branch information
sirainen authored and GitLab committed Feb 19, 2017
1 parent be6bde0 commit 2898ad0
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/doveadm/doveadm-mail.c
Expand Up @@ -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:
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/imap/imap-commands-util.c
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/lib-storage/index/dbox-multi/mdbox-map.c
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/lib-storage/index/imapc/imapc-storage.c
Expand Up @@ -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 }
Expand Down
2 changes: 2 additions & 0 deletions src/lib-storage/mail-error.h
Expand Up @@ -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,
Expand Down

0 comments on commit 2898ad0

Please sign in to comment.