dovecot-2.0: imap: Fixed SELECT QRESYNC not to crash on mailbox ...
dovecot at dovecot.org
dovecot at dovecot.org
Tue Nov 2 19:14:30 EET 2010
details: http://hg.dovecot.org/dovecot-2.0/rev/1d381325a973
changeset: 12362:1d381325a973
user: Timo Sirainen <tss at iki.fi>
date: Tue Nov 02 17:14:25 2010 +0000
description:
imap: Fixed SELECT QRESYNC not to crash on mailbox close if a lot of changes were being sent.
diffstat:
src/imap/cmd-select.c | 13 +++++++++----
src/imap/imap-client.c | 2 ++
src/imap/main.c | 6 ++++++
3 files changed, 17 insertions(+), 4 deletions(-)
diffs (87 lines):
diff -r 5a8533404979 -r 1d381325a973 src/imap/cmd-select.c
--- a/src/imap/cmd-select.c Tue Nov 02 15:39:28 2010 +0000
+++ b/src/imap/cmd-select.c Tue Nov 02 17:14:25 2010 +0000
@@ -263,11 +263,11 @@
ctx->cmd->func = cmd_select_continue;
ctx->cmd->context = ctx;
- return FALSE;
+ return 0;
}
}
- return imap_fetch_deinit(fetch_ctx);
+ return imap_fetch_deinit(fetch_ctx) < 0 ? -1 : 1;
}
static int
@@ -276,6 +276,7 @@
struct client *client = ctx->cmd->client;
struct mailbox_status status;
enum mailbox_flags flags = 0;
+ int ret;
if (readonly)
flags |= MAILBOX_FLAG_READONLY | MAILBOX_FLAG_KEEP_RECENT;
@@ -339,13 +340,15 @@
}
if (ctx->qresync_uid_validity == status.uidvalidity) {
- if (select_qresync(ctx) < 0) {
+ if ((ret = select_qresync(ctx)) < 0) {
client_send_storage_error(ctx->cmd,
mailbox_get_storage(ctx->box));
return -1;
}
+ } else {
+ ret = 1;
}
- return 0;
+ return ret;
}
static void close_selected_mailbox(struct client *client)
@@ -424,6 +427,8 @@
}
ret = select_open(ctx, storage_name, readonly);
+ if (ret == 0)
+ return FALSE;
cmd_select_finish(ctx, ret);
return TRUE;
}
diff -r 5a8533404979 -r 1d381325a973 src/imap/imap-client.c
--- a/src/imap/imap-client.c Tue Nov 02 15:39:28 2010 +0000
+++ b/src/imap/imap-client.c Tue Nov 02 17:14:25 2010 +0000
@@ -424,6 +424,8 @@
cmd = new_cmd->client->command_queue;
for (; cmd != NULL; cmd = cmd->next) {
+ i_warning("cmd=%s state=%d<=%d flags=%x & %x",
+ cmd->name, cmd->state, max_state, cmd->cmd_flags, flags);
if (cmd->state <= max_state &&
cmd != new_cmd && (cmd->cmd_flags & flags) != 0)
return cmd;
diff -r 5a8533404979 -r 1d381325a973 src/imap/main.c
--- a/src/imap/main.c Tue Nov 02 15:39:28 2010 +0000
+++ b/src/imap/main.c Tue Nov 02 17:14:25 2010 +0000
@@ -250,6 +250,7 @@
login_client_connected(const struct master_login_client *client,
const char *username, const char *const *extra_fields)
{
+#define MSG_BYE_INTERNAL_ERROR "* BYE "MAIL_ERRSTR_CRITICAL_MSG"\r\n"
struct mail_storage_service_input input;
const char *error;
buffer_t input_buf;
@@ -265,6 +266,11 @@
client->auth_req.data_size);
if (client_create_from_input(&input, client, client->fd, client->fd,
&input_buf, &error) < 0) {
+ if (write(client->fd, MSG_BYE_INTERNAL_ERROR,
+ strlen(MSG_BYE_INTERNAL_ERROR)) < 0) {
+ if (errno != EAGAIN && errno != EPIPE)
+ i_error("write(client) failed: %m");
+ }
i_error("%s", error);
(void)close(client->fd);
master_service_client_connection_destroyed(master_service);
More information about the dovecot-cvs
mailing list