[dovecot-cvs] dovecot/src/lib-index mail-cache.c, 1.64, 1.65 mail-index-private.h, 1.51, 1.52 mail-index.c, 1.193, 1.194

cras at dovecot.org cras at dovecot.org
Fri Mar 25 00:12:14 EET 2005


Update of /var/lib/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv9924/lib-index

Modified Files:
	mail-cache.c mail-index-private.h mail-index.c 
Log Message:
Added sync/sync_lost/expunge handler unregistering, and also do that. Fixes
crash with mmap_disable=yes when reopening mailbox.



Index: mail-cache.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-cache.c,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -d -r1.64 -r1.65
--- mail-cache.c	12 Mar 2005 18:16:29 -0000	1.64
+++ mail-cache.c	24 Mar 2005 22:12:12 -0000	1.65
@@ -307,10 +307,16 @@
 void mail_cache_free(struct mail_cache *cache)
 {
 	if (cache->file_cache != NULL) {
+		mail_index_unregister_sync_lost_handler(cache->index,
+			mail_cache_sync_lost_handler);
+
 		file_cache_free(cache->file_cache);
 		cache->file_cache = NULL;
 	}
 
+	mail_index_unregister_expunge_handler(cache->index, cache->ext_id);
+	mail_index_unregister_sync_handler(cache->index, cache->ext_id);
+
 	mail_cache_file_close(cache);
 
 	hash_destroy(cache->field_name_hash);

Index: mail-index-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-private.h,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -d -r1.51 -r1.52
--- mail-index-private.h	12 Mar 2005 18:16:29 -0000	1.51
+++ mail-index-private.h	24 Mar 2005 22:12:12 -0000	1.52
@@ -173,11 +173,17 @@
 void mail_index_register_expunge_handler(struct mail_index *index,
 					 uint32_t ext_id,
 					 mail_index_expunge_handler_t *cb);
+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,
+					mail_index_sync_lost_handler_t *cb);
 
 int mail_index_write_base_header(struct mail_index *index,
 				 const struct mail_index_header *hdr);

Index: mail-index.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index.c,v
retrieving revision 1.193
retrieving revision 1.194
diff -u -d -r1.193 -r1.194
--- mail-index.c	24 Mar 2005 20:28:28 -0000	1.193
+++ mail-index.c	24 Mar 2005 22:12:12 -0000	1.194
@@ -108,7 +108,23 @@
 					 uint32_t ext_id,
 					 mail_index_expunge_handler_t *cb)
 {
-	array_idx_set(&index->expunge_handlers, ext_id, &cb);
+        mail_index_expunge_handler_t **p;
+
+	p = array_modifyable_idx(&index->expunge_handlers, ext_id);
+	i_assert(*p == NULL);
+
+	*p = cb;
+}
+
+void mail_index_unregister_expunge_handler(struct mail_index *index,
+					   uint32_t ext_id)
+{
+        mail_index_expunge_handler_t **p;
+
+	p = array_modifyable_idx(&index->expunge_handlers, ext_id);
+	i_assert(*p != NULL);
+
+	*p = NULL;
 }
 
 void mail_index_register_sync_handler(struct mail_index *index, uint32_t ext_id,
@@ -118,16 +134,45 @@
 	struct mail_index_sync_handler *h;
 
 	h = array_modifyable_idx(&index->sync_handlers, ext_id);
+	i_assert(h->callback == NULL);
+
 	h->callback = cb;
 	h->type = type;
 }
 
+void mail_index_unregister_sync_handler(struct mail_index *index,
+					uint32_t ext_id)
+{
+	struct mail_index_sync_handler *h;
+
+	h = array_modifyable_idx(&index->sync_handlers, ext_id);
+	i_assert(h->callback != NULL);
+
+	h->callback = NULL;
+	h->type = 0;
+}
+
 void mail_index_register_sync_lost_handler(struct mail_index *index,
 					   mail_index_sync_lost_handler_t *cb)
 {
 	array_append(&index->sync_lost_handlers, &cb, 1);
 }
 
+void mail_index_unregister_sync_lost_handler(struct mail_index *index,
+					     mail_index_sync_lost_handler_t *cb)
+{
+	mail_index_sync_lost_handler_t *const *handlers;
+	unsigned int i, count;
+
+	handlers = array_get(&index->sync_lost_handlers, &count);
+	for (i = 0; i < count; i++) {
+		if (handlers[i] == cb) {
+			array_delete(&index->sync_lost_handlers, i, 1);
+			break;
+		}
+	}
+}
+
 static void mail_index_map_init_extbufs(struct mail_index_map *map,
 					unsigned int initial_count)
 {



More information about the dovecot-cvs mailing list