changeset 22929:63b7e595a0fe

lib-index: Remove extension record sync handlers This is no longer used by anything, and it makes the fix in the following commit much easier. This was originally added in 6a19e109ee8c5a6f688da83a86a7f6abeb71abdd to allow dovecot.index.cache updating to hook into updating cache offsets to link cache records together. This was reimplemented in a different way in 131b073bdc3650083b00616dc778dd3017c2bbb5
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Sun, 29 Apr 2018 12:23:49 +0300
parents 057fa2be3603
children bfeda12bb54a
files src/lib-index/mail-index-private.h src/lib-index/mail-index-sync-ext.c src/lib-index/mail-index.c
diffstat 3 files changed, 2 insertions(+), 75 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-index-private.h	Thu Apr 26 13:18:01 2018 +0300
+++ b/src/lib-index/mail-index-private.h	Sun Apr 29 12:23:49 2018 +0300
@@ -45,9 +45,6 @@
 typedef int mail_index_expunge_handler_t(struct mail_index_sync_map_ctx *ctx,
 					 uint32_t seq, const void *data,
 					 void **sync_context, void *context);
-typedef int mail_index_sync_handler_t(struct mail_index_sync_map_ctx *ctx,
-				      uint32_t seq, void *old_data,
-				      const void *new_data, void **context);
 typedef void mail_index_sync_lost_handler_t(struct mail_index *index);
 
 #define MAIL_INDEX_HEADER_SIZE_ALIGN(size) \
@@ -93,11 +90,6 @@
 	MAIL_INDEX_SYNC_HANDLER_VIEW	= 0x04
 };
 
-struct mail_index_sync_handler {
-	mail_index_sync_handler_t *callback;
-        enum mail_index_sync_handler_type type;
-};
-
 struct mail_index_registered_ext {
 	const char *name;
 	uint32_t index_idx; /* index ext_id */
@@ -105,7 +97,6 @@
 	uint16_t record_size;
 	uint16_t record_align;
 
-	struct mail_index_sync_handler sync_handler;
 	mail_index_expunge_handler_t *expunge_handler;
 
 	void *expunge_context;
@@ -242,11 +233,6 @@
 					 void *context);
 void mail_index_unregister_expunge_handler(struct mail_index *index,
 					   uint32_t ext_id);
-void mail_index_register_sync_handler(struct mail_index *index, uint32_t ext_id,
-				      mail_index_sync_handler_t *cb,
-				      enum mail_index_sync_handler_type type);
-void mail_index_unregister_sync_handler(struct mail_index *index,
-					uint32_t ext_id);
 void mail_index_register_sync_lost_handler(struct mail_index *index,
 					   mail_index_sync_lost_handler_t *cb);
 void mail_index_unregister_sync_lost_handler(struct mail_index *index,
--- a/src/lib-index/mail-index-sync-ext.c	Thu Apr 26 13:18:01 2018 +0300
+++ b/src/lib-index/mail-index-sync-ext.c	Sun Apr 29 12:23:49 2018 +0300
@@ -94,26 +94,8 @@
 
 void mail_index_sync_deinit_handlers(struct mail_index_sync_map_ctx *ctx)
 {
-	const struct mail_index_registered_ext *rext;
-	void **extra_contexts;
-	unsigned int i, rext_count, context_count;
-
-	if (!array_is_created(&ctx->extra_contexts))
-		return;
-
-	rext = array_get(&ctx->view->index->extensions, &rext_count);
-	extra_contexts =
-		array_get_modifiable(&ctx->extra_contexts, &context_count);
-	i_assert(context_count <= rext_count);
-
-	for (i = 0; i < context_count; i++) {
-		if (extra_contexts[i] != NULL) {
-			rext[i].sync_handler.callback(ctx, 0, NULL, NULL,
-						      &extra_contexts[i]);
-		}
-	}
-
-	array_free(&ctx->extra_contexts);
+	if (array_is_created(&ctx->extra_contexts))
+		array_free(&ctx->extra_contexts);
 }
 
 static struct mail_index_ext_header *
@@ -660,10 +642,8 @@
 	struct mail_index_view *view = ctx->view;
 	struct mail_index_record *rec;
 	const struct mail_index_ext *ext;
-	const struct mail_index_registered_ext *rext;
 	void *old_data;
 	uint32_t seq;
-	int ret;
 
 	i_assert(ctx->cur_ext_map_idx != (uint32_t)-1);
 	i_assert(!ctx->cur_ext_ignore);
@@ -684,20 +664,6 @@
 	rec = MAIL_INDEX_REC_AT_SEQ(view->map, seq);
 	old_data = PTR_OFFSET(rec, ext->record_offset);
 
-	rext = array_idx(&view->index->extensions, ext->index_idx);
-
-	/* call sync handlers only when its registered type matches with
-	   current synchronization type (index/view) */
-	if ((rext->sync_handler.type & ctx->type) != 0) {
-		void **extra_context =
-			array_idx_modifiable(&ctx->extra_contexts,
-					     ext->index_idx);
-		ret = rext->sync_handler.callback(ctx, seq, old_data, u + 1,
-						  extra_context);
-		if (ret <= 0)
-			return ret;
-	}
-
 	/* @UNSAFE */
 	memcpy(old_data, u + 1, ctx->cur_ext_record_size);
 	if (ctx->cur_ext_record_size < ext->record_size) {
--- a/src/lib-index/mail-index.c	Thu Apr 26 13:18:01 2018 +0300
+++ b/src/lib-index/mail-index.c	Sun Apr 29 12:23:49 2018 +0300
@@ -315,31 +315,6 @@
 	rext->expunge_handler = NULL;
 }
 
-void mail_index_register_sync_handler(struct mail_index *index, uint32_t ext_id,
-				      mail_index_sync_handler_t *cb,
-				      enum mail_index_sync_handler_type type)
-{
-	struct mail_index_registered_ext *rext;
-
-	rext = array_idx_modifiable(&index->extensions, ext_id);
-	i_assert(rext->sync_handler.callback == NULL);
-
-	rext->sync_handler.callback = cb;
-	rext->sync_handler.type = type;
-}
-
-void mail_index_unregister_sync_handler(struct mail_index *index,
-					uint32_t ext_id)
-{
-	struct mail_index_registered_ext *rext;
-
-	rext = array_idx_modifiable(&index->extensions, ext_id);
-	i_assert(rext->sync_handler.callback != NULL);
-
-	rext->sync_handler.callback = NULL;
-	rext->sync_handler.type = 0;
-}
-
 void mail_index_register_sync_lost_handler(struct mail_index *index,
 					   mail_index_sync_lost_handler_t *cb)
 {