changeset 26383:d551f035cefd

index: Pass index sync flags to index view sync for pvt When recovering from inconsistent view, this needs to passed for pvt indexes too. Fixes Error: dovecot.index.pvt reset, view is now inconsistent
author Aki Tuomi <aki.tuomi@open-xchange.com>
date Tue, 02 Jul 2019 19:33:59 +0300
parents 1b37db2cfaed
children fcd3ffab1515
files src/lib-storage/index/index-sync-private.h src/lib-storage/index/index-sync-pvt.c src/lib-storage/index/index-sync.c src/lib-storage/index/index-transaction.c
diffstat 4 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/index-sync-private.h	Tue Sep 17 19:52:25 2019 +0300
+++ b/src/lib-storage/index/index-sync-private.h	Tue Jul 02 19:33:59 2019 +0300
@@ -26,6 +26,7 @@
 
 /* Returns 1 = ok, 0 = no private indexes, -1 = error */
 int index_mailbox_sync_pvt_init(struct mailbox *box, bool lock,
+				enum mail_index_view_sync_flags flags,
 				struct index_mailbox_sync_pvt_context **ctx_r);
 int index_mailbox_sync_pvt_newmails(struct index_mailbox_sync_pvt_context *ctx,
 				    struct mailbox_transaction_context *trans);
--- a/src/lib-storage/index/index-sync-pvt.c	Tue Sep 17 19:52:25 2019 +0300
+++ b/src/lib-storage/index/index-sync-pvt.c	Tue Jul 02 19:33:59 2019 +0300
@@ -11,6 +11,8 @@
 	struct mail_index_view *view_pvt;
 	struct mail_index_transaction *trans_pvt;
 	struct mail_index_view *view_shared;
+
+	enum mail_index_view_sync_flags flags;
 };
 
 static int sync_pvt_expunges(struct index_mailbox_sync_pvt_context *ctx)
@@ -123,6 +125,7 @@
 }
 
 int index_mailbox_sync_pvt_init(struct mailbox *box, bool lock,
+				enum mail_index_view_sync_flags flags,
 				struct index_mailbox_sync_pvt_context **ctx_r)
 {
 	struct index_mailbox_sync_pvt_context *ctx;
@@ -135,6 +138,7 @@
 
 	ctx = i_new(struct index_mailbox_sync_pvt_context, 1);
 	ctx->box = box;
+	ctx->flags = flags;
 	if (lock) {
 		if (index_mailbox_sync_open(ctx, TRUE) < 0) {
 			index_mailbox_sync_pvt_deinit(&ctx);
@@ -300,7 +304,7 @@
 		return -1;
 
 	/* sync the private view */
-	view_sync_ctx = mail_index_view_sync_begin(ctx->box->view_pvt, 0);
+	view_sync_ctx = mail_index_view_sync_begin(ctx->box->view_pvt, ctx->flags);
 	while (mail_index_view_sync_next(view_sync_ctx, &sync_rec)) {
 		if (sync_rec.type != MAIL_INDEX_VIEW_SYNC_TYPE_FLAGS)
 			continue;
--- a/src/lib-storage/index/index-sync.c	Tue Sep 17 19:52:25 2019 +0300
+++ b/src/lib-storage/index/index-sync.c	Tue Jul 02 19:33:59 2019 +0300
@@ -144,7 +144,7 @@
 	   doesn't matter if it's called at _sync_init() or _sync_deinit().
 	   however we also need to know if any private flags have changed
 	   since last sync, so we need to call it before _sync_next() calls. */
-	if (index_mailbox_sync_pvt_init(box, FALSE, &pvt_ctx) > 0) {
+	if (index_mailbox_sync_pvt_init(box, FALSE, sync_flags, &pvt_ctx) > 0) {
 		(void)index_mailbox_sync_pvt_view(pvt_ctx, &ctx->flag_updates,
 						  &ctx->hidden_updates);
 		index_mailbox_sync_pvt_deinit(&pvt_ctx);
--- a/src/lib-storage/index/index-transaction.c	Tue Sep 17 19:52:25 2019 +0300
+++ b/src/lib-storage/index/index-transaction.c	Tue Jul 02 19:33:59 2019 +0300
@@ -60,7 +60,7 @@
 	}
 
 	if (array_is_created(&t->pvt_saves)) {
-		if (index_mailbox_sync_pvt_init(t->box, TRUE, &pvt_sync_ctx) < 0)
+		if (index_mailbox_sync_pvt_init(t->box, TRUE, 0, &pvt_sync_ctx) < 0)
 			ret = -1;
 	}