dovecot-2.0: virtual: Fixed handling multiple mailboxes using th...

dovecot at dovecot.org dovecot at dovecot.org
Mon May 18 01:29:50 EEST 2009


details:   http://hg.dovecot.org/dovecot-2.0/rev/7c4af82cb5e7
changeset: 9314:7c4af82cb5e7
user:      Timo Sirainen <tss at iki.fi>
date:      Sun May 17 18:29:35 2009 -0400
description:
virtual: Fixed handling multiple mailboxes using the same search args.

diffstat:

3 files changed, 18 insertions(+), 3 deletions(-)
src/plugins/virtual/virtual-config.c  |   16 ++++++++++++++++
src/plugins/virtual/virtual-storage.c |    2 ++
src/plugins/virtual/virtual-sync.c    |    3 ---

diffs (65 lines):

diff -r 47d22004ea13 -r 7c4af82cb5e7 src/plugins/virtual/virtual-config.c
--- a/src/plugins/virtual/virtual-config.c	Sun May 17 18:28:55 2009 -0400
+++ b/src/plugins/virtual/virtual-config.c	Sun May 17 18:29:35 2009 -0400
@@ -289,6 +289,20 @@ static int virtual_config_expand_wildcar
 	for (i = 0; i < count; i++)
 		mail_search_args_unref(&wboxes[i]->search_args);
 	return mailbox_list_iter_deinit(&iter);
+}
+
+static void virtual_config_search_args_dup(struct virtual_mailbox *mbox)
+{
+	struct virtual_backend_box *const *bboxes;
+	struct mail_search_args *old_args;
+	unsigned int i, count;
+
+	bboxes = array_get_modifiable(&mbox->backend_boxes, &count);
+	for (i = 0; i < count; i++) {
+		old_args = bboxes[i]->search_args;
+		bboxes[i]->search_args = mail_search_args_dup(old_args);
+		mail_search_args_unref(&old_args);
+	}
 }
 
 int virtual_config_read(struct virtual_mailbox *mbox)
@@ -356,6 +370,8 @@ int virtual_config_read(struct virtual_m
 					  "%s: No mailboxes defined", path);
 		ret = -1;
 	}
+	if (ret == 0)
+		virtual_config_search_args_dup(mbox);
 	i_stream_unref(&ctx.input);
 	(void)close(fd);
 	return ret;
diff -r 47d22004ea13 -r 7c4af82cb5e7 src/plugins/virtual/virtual-storage.c
--- a/src/plugins/virtual/virtual-storage.c	Sun May 17 18:28:55 2009 -0400
+++ b/src/plugins/virtual/virtual-storage.c	Sun May 17 18:29:35 2009 -0400
@@ -229,6 +229,8 @@ static int virtual_mailboxes_open(struct
 		}
 		i_array_init(&bboxes[i]->uids, 64);
 		i_array_init(&bboxes[i]->sync_pending_removes, 64);
+		mail_search_args_init(bboxes[i]->search_args, bboxes[i]->box,
+				      FALSE, NULL);
 	}
 	if (i == count)
 		return 0;
diff -r 47d22004ea13 -r 7c4af82cb5e7 src/plugins/virtual/virtual-sync.c
--- a/src/plugins/virtual/virtual-sync.c	Sun May 17 18:28:55 2009 -0400
+++ b/src/plugins/virtual/virtual-sync.c	Sun May 17 18:29:35 2009 -0400
@@ -469,7 +469,6 @@ static int virtual_sync_backend_box_init
 	ret = mailbox_search_deinit(&search_ctx);
 	mail_free(&mail);
 
-	mail_search_args_deinit(bbox->search_args);
 	(void)mailbox_transaction_commit(&trans);
 	return ret;
 }
@@ -912,8 +911,6 @@ static int virtual_sync_backend_box(stru
 				 &status) < 0)
 			return -1;
 
-		mail_search_args_init(bbox->search_args, bbox->box,
-				      FALSE, NULL);
 		virtual_backend_box_sync_mail_set(bbox);
 		if (status.uidvalidity != bbox->sync_uid_validity) {
 			/* UID validity changed since last sync (or this is


More information about the dovecot-cvs mailing list