dovecot-2.2: imap: Added client_disconnect_if_inconsistent() to ...
dovecot at dovecot.org
dovecot at dovecot.org
Fri Nov 14 08:24:35 UTC 2014
details: http://hg.dovecot.org/dovecot-2.2/rev/0f81d0ea3a48
changeset: 18087:0f81d0ea3a48
user: Timo Sirainen <tss at iki.fi>
date: Fri Nov 14 02:29:27 2014 +0200
description:
imap: Added client_disconnect_if_inconsistent() to remove code duplication.
Based on patch by Stephan Bosch
diffstat:
src/imap/imap-commands-util.c | 24 ++++++++++++------------
src/imap/imap-commands-util.h | 2 ++
2 files changed, 14 insertions(+), 12 deletions(-)
diffs (60 lines):
diff -r 2fff557c9837 -r 0f81d0ea3a48 src/imap/imap-commands-util.c
--- a/src/imap/imap-commands-util.c Thu Nov 13 22:55:59 2014 -0800
+++ b/src/imap/imap-commands-util.c Fri Nov 14 02:29:27 2014 +0200
@@ -170,6 +170,16 @@
error));
}
+void client_disconnect_if_inconsistent(struct client *client)
+{
+ if (client->mailbox != NULL &&
+ mailbox_is_inconsistent(client->mailbox)) {
+ /* we can't do forced CLOSE, so have to disconnect */
+ client_disconnect_with_error(client,
+ "IMAP session state is inconsistent, please relogin.");
+ }
+}
+
void client_send_box_error(struct client_command_context *cmd,
struct mailbox *box)
{
@@ -186,12 +196,7 @@
client_send_tagline(cmd, imap_get_error_string(cmd, error_string,
error));
- if (cmd->client->mailbox != NULL &&
- mailbox_is_inconsistent(cmd->client->mailbox)) {
- /* we can't do forced CLOSE, so have to disconnect */
- client_disconnect_with_error(cmd->client,
- "IMAP session state is inconsistent, please relogin.");
- }
+ client_disconnect_if_inconsistent(cmd->client);
}
void client_send_untagged_storage_error(struct client *client,
@@ -203,12 +208,7 @@
error_string = mail_storage_get_last_error(storage, &error);
client_send_line(client, t_strconcat("* NO ", error_string, NULL));
- if (client->mailbox != NULL &&
- mailbox_is_inconsistent(client->mailbox)) {
- /* we can't do forced CLOSE, so have to disconnect */
- client_disconnect_with_error(client,
- "IMAP session state is inconsistent, please relogin.");
- }
+ client_disconnect_if_inconsistent(client);
}
bool client_parse_mail_flags(struct client_command_context *cmd,
diff -r 2fff557c9837 -r 0f81d0ea3a48 src/imap/imap-commands-util.h
--- a/src/imap/imap-commands-util.h Thu Nov 13 22:55:59 2014 -0800
+++ b/src/imap/imap-commands-util.h Fri Nov 14 02:29:27 2014 +0200
@@ -29,6 +29,8 @@
imap_get_error_string(struct client_command_context *cmd,
const char *error_string, enum mail_error error);
+void client_disconnect_if_inconsistent(struct client *client);
+
/* Send last mailbox list error message to client. */
void client_send_list_error(struct client_command_context *cmd,
struct mailbox_list *list);
More information about the dovecot-cvs
mailing list