dovecot-2.2: virtual: Fixed assert-crash when doing changes to b...
dovecot at dovecot.org
dovecot at dovecot.org
Fri May 2 06:29:38 UTC 2014
details: http://hg.dovecot.org/dovecot-2.2/rev/501a19fc2747
changeset: 17299:501a19fc2747
user: Timo Sirainen <tss at iki.fi>
date: Fri May 02 09:29:05 2014 +0300
description:
virtual: Fixed assert-crash when doing changes to backend mailbox via the virtual mailbox.
Caused by the recent lazy mailbox opening changes.
diffstat:
src/plugins/virtual/virtual-sync.c | 27 ++++++++++++++++++++-------
1 files changed, 20 insertions(+), 7 deletions(-)
diffs (81 lines):
diff -r c1719de47d5e -r 501a19fc2747 src/plugins/virtual/virtual-sync.c
--- a/src/plugins/virtual/virtual-sync.c Wed Apr 30 18:46:55 2014 +0300
+++ b/src/plugins/virtual/virtual-sync.c Fri May 02 09:29:05 2014 +0300
@@ -331,8 +331,8 @@
&ext_hdr.change_counter, sizeof(ext_hdr.change_counter));
}
-static void virtual_sync_index_rec(struct virtual_sync_context *ctx,
- const struct mail_index_sync_rec *sync_rec)
+static int virtual_sync_index_rec(struct virtual_sync_context *ctx,
+ const struct mail_index_sync_rec *sync_rec)
{
uint32_t virtual_ext_id = ctx->mbox->virtual_ext_id;
struct virtual_backend_box *bbox;
@@ -355,7 +355,7 @@
sync_rec->uid1, sync_rec->uid2,
&seq1, &seq2)) {
/* already expunged, nothing to do. */
- return;
+ return 0;
}
for (vseq = seq1; vseq <= seq2; vseq++) {
@@ -366,6 +366,13 @@
bbox = virtual_backend_box_lookup(ctx->mbox, vrec->mailbox_id);
if (bbox == NULL)
continue;
+ if (!bbox->box->opened) {
+ if (mailbox_open(bbox->box) < 0) {
+ virtual_box_copy_error(&ctx->mbox->box,
+ bbox->box);
+ return -1;
+ }
+ }
virtual_backend_box_sync_mail_set(bbox);
if (!mail_set_uid(bbox->sync_mail, vrec->real_uid)) {
@@ -405,9 +412,10 @@
break;
}
}
+ return 0;
}
-static void virtual_sync_index_changes(struct virtual_sync_context *ctx)
+static int virtual_sync_index_changes(struct virtual_sync_context *ctx)
{
const ARRAY_TYPE(keywords) *keywords;
struct mail_index_sync_rec sync_rec;
@@ -415,8 +423,11 @@
keywords = mail_index_get_keywords(ctx->index);
ctx->kw_all = array_count(keywords) == 0 ? NULL :
array_idx(keywords, 0);
- while (mail_index_sync_next(ctx->index_sync_ctx, &sync_rec))
- virtual_sync_index_rec(ctx, &sync_rec);
+ while (mail_index_sync_next(ctx->index_sync_ctx, &sync_rec)) {
+ if (virtual_sync_index_rec(ctx, &sync_rec) < 0)
+ return -1;
+ }
+ return 0;
}
static void virtual_sync_index_finish(struct virtual_sync_context *ctx)
@@ -1082,6 +1093,7 @@
}
} else {
/* sync using the existing search result */
+ i_assert(bbox_index_opened);
i_array_init(&ctx->sync_expunges, 32);
ret = virtual_sync_backend_box_sync(ctx, bbox, sync_flags);
if (ret == 0) T_BEGIN {
@@ -1511,7 +1523,8 @@
if (ret == 0)
ctx->ext_header_rewrite = TRUE;
/* apply changes from virtual index to backend mailboxes */
- virtual_sync_index_changes(ctx);
+ if (virtual_sync_index_changes(ctx) < 0)
+ return virtual_sync_finish(ctx, FALSE);
/* update list of UIDs in backend mailboxes */
if (virtual_sync_backend_boxes(ctx) < 0)
return virtual_sync_finish(ctx, FALSE);
More information about the dovecot-cvs
mailing list