dovecot-2.1: imapc: Fixed handling immediate changes when starti...

dovecot at dovecot.org dovecot at dovecot.org
Sun Sep 4 12:38:34 EEST 2011


details:   http://hg.dovecot.org/dovecot-2.1/rev/e404a1bef6bc
changeset: 13383:e404a1bef6bc
user:      Timo Sirainen <tss at iki.fi>
date:      Sun Sep 04 12:37:51 2011 +0300
description:
imapc: Fixed handling immediate changes when starting IDLE.

diffstat:

 src/lib-storage/index/imapc/imapc-client.c     |   9 ++++++-
 src/lib-storage/index/imapc/imapc-client.h     |   3 +-
 src/lib-storage/index/imapc/imapc-mail-fetch.c |   2 +-
 src/lib-storage/index/imapc/imapc-mail.c       |   2 +-
 src/lib-storage/index/imapc/imapc-save.c       |   4 +-
 src/lib-storage/index/imapc/imapc-storage.c    |  28 +++++++++++++++++++++++--
 src/lib-storage/index/imapc/imapc-storage.h    |   2 +
 src/lib-storage/index/imapc/imapc-sync.c       |   4 +-
 8 files changed, 42 insertions(+), 12 deletions(-)

diffs (170 lines):

diff -r b9c967c7d66b -r e404a1bef6bc src/lib-storage/index/imapc/imapc-client.c
--- a/src/lib-storage/index/imapc/imapc-client.c	Sun Sep 04 12:29:45 2011 +0300
+++ b/src/lib-storage/index/imapc/imapc-client.c	Sun Sep 04 12:37:51 2011 +0300
@@ -99,7 +99,7 @@
 	client->untagged_context = context;
 }
 
-void imapc_client_run(struct imapc_client *client)
+void imapc_client_run_pre(struct imapc_client *client)
 {
 	struct imapc_client_connection *const *connp;
 	struct ioloop *prev_ioloop = current_ioloop;
@@ -121,8 +121,13 @@
 
 	if (io_loop_is_running(client->ioloop))
 		io_loop_run(client->ioloop);
+	current_ioloop = prev_ioloop;
+}
 
-	current_ioloop = prev_ioloop;
+void imapc_client_run_post(struct imapc_client *client)
+{
+	struct imapc_client_connection *const *connp;
+
 	array_foreach(&client->conns, connp)
 		imapc_connection_ioloop_changed((*connp)->conn);
 
diff -r b9c967c7d66b -r e404a1bef6bc src/lib-storage/index/imapc/imapc-client.h
--- a/src/lib-storage/index/imapc/imapc-client.h	Sun Sep 04 12:29:45 2011 +0300
+++ b/src/lib-storage/index/imapc/imapc-client.h	Sun Sep 04 12:37:51 2011 +0300
@@ -112,7 +112,8 @@
 				    imapc_untagged_callback_t *callback,
 				    void *context);
 
-void imapc_client_run(struct imapc_client *client);
+void imapc_client_run_pre(struct imapc_client *client);
+void imapc_client_run_post(struct imapc_client *client);
 void imapc_client_stop(struct imapc_client *client);
 /* Stop immediately, don't finish even any already read pending replies.
    They'll be finished when imapc_client_run() is again called. */
diff -r b9c967c7d66b -r e404a1bef6bc src/lib-storage/index/imapc/imapc-mail-fetch.c
--- a/src/lib-storage/index/imapc/imapc-mail-fetch.c	Sun Sep 04 12:29:45 2011 +0300
+++ b/src/lib-storage/index/imapc/imapc-mail-fetch.c	Sun Sep 04 12:37:51 2011 +0300
@@ -156,7 +156,7 @@
 	   or until all FETCH replies have been received (i.e. some FETCHes
 	   failed) */
 	while (!imapc_mail_have_fields(imail, fields) && imail->fetch_count > 0)
-		imapc_client_run(storage->client);
+		imapc_storage_run(storage);
 	return 0;
 }
 
diff -r b9c967c7d66b -r e404a1bef6bc src/lib-storage/index/imapc/imapc-mail.c
--- a/src/lib-storage/index/imapc/imapc-mail.c	Sun Sep 04 12:29:45 2011 +0300
+++ b/src/lib-storage/index/imapc/imapc-mail.c	Sun Sep 04 12:37:51 2011 +0300
@@ -210,7 +210,7 @@
 		(struct imapc_storage *)_mail->box->storage;
 
 	while (imail->fetch_count > 0)
-		imapc_client_run(storage->client);
+		imapc_storage_run(storage);
 	index_mail_close(_mail);
 }
 
diff -r b9c967c7d66b -r e404a1bef6bc src/lib-storage/index/imapc/imapc-save.c
--- a/src/lib-storage/index/imapc/imapc-save.c	Sun Sep 04 12:29:45 2011 +0300
+++ b/src/lib-storage/index/imapc/imapc-save.c	Sun Sep 04 12:37:51 2011 +0300
@@ -191,7 +191,7 @@
 			  ctx->mbox->box.name, flags, internaldate, input);
 	i_stream_unref(&input);
 	while (sctx.ret == -2)
-		imapc_client_run(ctx->mbox->storage->client);
+		imapc_storage_run(ctx->mbox->storage);
 	return sctx.ret;
 }
 
@@ -337,7 +337,7 @@
 					  "UID COPY %u %s",
 					  mail->uid, _t->box->name);
 		while (sctx.ret == -2)
-			imapc_client_run(src_mbox->storage->client);
+			imapc_storage_run(src_mbox->storage);
 		ctx->finished = TRUE;
 		return sctx.ret;
 	}
diff -r b9c967c7d66b -r e404a1bef6bc src/lib-storage/index/imapc/imapc-storage.c
--- a/src/lib-storage/index/imapc/imapc-storage.c	Sun Sep 04 12:29:45 2011 +0300
+++ b/src/lib-storage/index/imapc/imapc-storage.c	Sun Sep 04 12:37:51 2011 +0300
@@ -6,7 +6,8 @@
 #include "imap-arg.h"
 #include "imap-resp-code.h"
 #include "imapc-mail.h"
-#include "imapc-client.h"
+#include "imapc-client-private.h"
+#include "imapc-connection.h"
 #include "imapc-list.h"
 #include "imapc-sync.h"
 #include "imapc-settings.h"
@@ -105,7 +106,28 @@
 void imapc_simple_run(struct imapc_simple_context *sctx)
 {
 	while (sctx->ret == -2)
-		imapc_client_run(sctx->storage->client);
+		imapc_storage_run(sctx->storage);
+}
+
+void imapc_storage_run(struct imapc_storage *storage)
+{
+	struct imapc_client_mailbox *client_box;
+	struct imapc_client_connection *const *connp;
+	struct imapc_mailbox *mbox;
+
+	imapc_client_run_pre(storage->client);
+
+	array_foreach(&storage->client->conns, connp) {
+		client_box = imapc_connection_get_mailbox((*connp)->conn);
+		if (client_box == NULL)
+			continue;
+
+		mbox = client_box->untagged_box_context;
+		if (mbox->to_idle_delay != NULL)
+			mbox->to_idle_delay = io_loop_move_timeout(&mbox->to_idle_delay);
+	}
+
+	imapc_client_run_post(storage->client);
 }
 
 void imapc_simple_callback(const struct imapc_command_reply *reply,
@@ -333,7 +355,7 @@
 					  imapc_mailbox_open_callback,
 					  &ctx, mbox);
 	while (ctx.ret == -2)
-		imapc_client_run(mbox->storage->client);
+		imapc_storage_run(mbox->storage);
 	mbox->opening = FALSE;
 	if (!mbox->open_success) {
 		mailbox_close(box);
diff -r b9c967c7d66b -r e404a1bef6bc src/lib-storage/index/imapc/imapc-storage.h
--- a/src/lib-storage/index/imapc/imapc-storage.h	Sun Sep 04 12:29:45 2011 +0300
+++ b/src/lib-storage/index/imapc/imapc-storage.h	Sun Sep 04 12:37:51 2011 +0300
@@ -79,6 +79,8 @@
 					struct mail_index_transaction_commit_result *result);
 void imapc_transaction_save_rollback(struct mail_save_context *ctx);
 
+void imapc_storage_run(struct imapc_storage *storage);
+
 void imapc_copy_error_from_reply(struct imapc_storage *storage,
 				 enum mail_error default_error,
 				 const struct imapc_command_reply *reply);
diff -r b9c967c7d66b -r e404a1bef6bc src/lib-storage/index/imapc/imapc-sync.c
--- a/src/lib-storage/index/imapc/imapc-sync.c	Sun Sep 04 12:29:45 2011 +0300
+++ b/src/lib-storage/index/imapc/imapc-sync.c	Sun Sep 04 12:37:51 2011 +0300
@@ -204,7 +204,7 @@
 
 	imapc_sync_expunge_finish(ctx);
 	while (ctx->sync_command_count > 0)
-		imapc_client_run(ctx->mbox->storage->client);
+		imapc_storage_run(ctx->mbox->storage);
 	array_free(&ctx->expunged_uids);
 
 	if (box->v.sync_notify != NULL)
@@ -316,7 +316,7 @@
 		imapc_client_mailbox_cmdf(mbox->client_box,
 					  imapc_noop_stop_callback,
 					  mbox->storage, "NOOP");
-		imapc_client_run(mbox->storage->client);
+		imapc_storage_run(mbox->storage);
 	}
 
 	if (imapc_mailbox_commit_delayed_trans(mbox, &changes) < 0)


More information about the dovecot-cvs mailing list