[dovecot-cvs] dovecot/src/lib-index mail-cache-private.h, 1.19, 1.20 mail-cache-sync-update.c, 1.6, 1.7 mail-cache.c, 1.57, 1.58 mail-index-private.h, 1.40, 1.41 mail-index.c, 1.175, 1.176

cras at dovecot.org cras at dovecot.org
Sun Dec 5 03:38:19 EET 2004


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

Modified Files:
	mail-cache-private.h mail-cache-sync-update.c mail-cache.c 
	mail-index-private.h mail-index.c 
Log Message:
Added "sync lost" handlers which are called with mmap_disable=yes when index
file is re-read without going through all of the transaction log.



Index: mail-cache-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-cache-private.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- mail-cache-private.h	29 Nov 2004 12:30:27 -0000	1.19
+++ mail-cache-private.h	5 Dec 2004 01:38:17 -0000	1.20
@@ -207,6 +207,7 @@
 int mail_cache_sync_handler(struct mail_index_sync_map_ctx *sync_ctx,
 			    uint32_t seq, void *old_data, const void *new_data,
 			    void **context);
+void mail_cache_sync_lost_handler(struct mail_index *index);
 
 void mail_cache_set_syscall_error(struct mail_cache *cache,
 				  const char *function);

Index: mail-cache-sync-update.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-cache-sync-update.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- mail-cache-sync-update.c	5 Dec 2004 01:36:14 -0000	1.6
+++ mail-cache-sync-update.c	5 Dec 2004 01:38:17 -0000	1.7
@@ -146,3 +146,8 @@
 
 	return 1;
 }
+
+void mail_cache_sync_lost_handler(struct mail_index *index)
+{
+	file_cache_invalidate(index->cache->file_cache, 0, (uoff_t)-1);
+}

Index: mail-cache.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-cache.c,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -d -r1.57 -r1.58
--- mail-cache.c	4 Dec 2004 21:55:41 -0000	1.57
+++ mail-cache.c	5 Dec 2004 01:38:17 -0000	1.58
@@ -274,6 +274,10 @@
                                          MAIL_INDEX_SYNC_HANDLER_INDEX |
 					 (cache->file_cache == NULL ? 0 :
 					  MAIL_INDEX_SYNC_HANDLER_VIEW));
+	if (cache->file_cache != NULL) {
+		mail_index_register_sync_lost_handler(index,
+			mail_cache_sync_lost_handler);
+	}
 	return cache;
 }
 

Index: mail-index-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-private.h,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- mail-index-private.h	29 Nov 2004 18:01:26 -0000	1.40
+++ mail-index-private.h	5 Dec 2004 01:38:17 -0000	1.41
@@ -34,6 +34,7 @@
 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) \
 	(((size) + 7) & ~7)
@@ -94,6 +95,7 @@
 
 	buffer_t *expunge_handlers; /* mail_index_expunge_handler_t*[] */
 	buffer_t *sync_handlers; /* mail_index_sync_handler_t*[] */
+	buffer_t *sync_lost_handlers; /* mail_index_sync_lost_handler_t*[] */
 
 	char *filepath;
 	int fd;
@@ -144,6 +146,8 @@
 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_register_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.175
retrieving revision 1.176
diff -u -d -r1.175 -r1.176
--- mail-index.c	3 Dec 2004 04:58:37 -0000	1.175
+++ mail-index.c	5 Dec 2004 01:38:17 -0000	1.176
@@ -29,6 +29,7 @@
 	index->extension_pool = pool_alloconly_create("extension", 256);
 	index->extensions = buffer_create_dynamic(index->extension_pool, 64);
         index->sync_handlers = buffer_create_dynamic(default_pool, 64);
+        index->sync_lost_handlers = buffer_create_dynamic(default_pool, 64);
         index->expunge_handlers = buffer_create_dynamic(default_pool, 32);
 
 	index->mode = 0600;
@@ -42,6 +43,7 @@
 	pool_unref(index->extension_pool);
 
 	buffer_free(index->sync_handlers);
+	buffer_free(index->sync_lost_handlers);
 	buffer_free(index->expunge_handlers);
 
 	i_free(index->error);
@@ -112,6 +114,12 @@
 	buffer_write(index->sync_handlers, ext_id * sizeof(h), &h, sizeof(h));
 }
 
+void mail_index_register_sync_lost_handler(struct mail_index *index,
+					   mail_index_sync_lost_handler_t *cb)
+{
+	buffer_append(index->sync_lost_handlers, &cb, sizeof(cb));
+}
+
 static void mail_index_map_init_extbufs(struct mail_index_map *map,
 					unsigned int initial_count)
 {
@@ -642,7 +650,10 @@
 					  struct mail_index_map **map,
 					  int sync_to_index)
 {
-	int i, ret, retry;
+	mail_index_sync_lost_handler_t *const *handlers;
+	size_t size;
+	unsigned int i;
+	int ret, retry;
 
 	if ((*map)->hdr.indexid != 0) {
 		/* sync this as a view from transaction log. */
@@ -652,10 +663,15 @@
 			return ret;
 
 		/* transaction log lost/broken, fallback to re-reading it */
-		/* FIXME: file cache need to be reset (except not really with
-		   sync_to_index if we were just rewinding..) */
 	}
 
+	/* notify all "sync lost" handlers */
+	handlers = buffer_get_data(index->sync_lost_handlers, &size);
+	size /= sizeof(*handlers);
+
+	for (i = 0; i < size; i++)
+		(*handlers[i])(index);
+
 	for (i = 0; i < MAIL_INDEX_ESTALE_RETRY_COUNT; i++) {
 		ret = mail_index_read_map(index, *map, &retry);
 		if (ret != 0 || !retry)



More information about the dovecot-cvs mailing list