[dovecot-cvs] dovecot/src/lib-storage/index index-storage.c, 1.82, 1.83 index-storage.h, 1.98, 1.99

cras at dovecot.org cras at dovecot.org
Thu Jan 19 01:14:46 EET 2006


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

Modified Files:
	index-storage.c index-storage.h 
Log Message:
Added mbox_min_index_size setting.



Index: index-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-storage.c,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -d -r1.82 -r1.83
--- index-storage.c	18 Jan 2006 22:16:43 -0000	1.82
+++ index-storage.c	18 Jan 2006 23:14:44 -0000	1.83
@@ -311,11 +311,13 @@
 
 int index_storage_mailbox_init(struct index_mailbox *ibox,
 			       struct mail_index *index, const char *name,
-			       enum mailbox_open_flags flags)
+			       enum mailbox_open_flags flags,
+			       bool move_to_memory)
 {
 	struct mail_storage *storage = &ibox->storage->storage;
 	enum mail_index_open_flags index_flags;
 	enum mail_index_lock_method lock_method = 0;
+	int ret;
 
 	i_assert(name != NULL);
 
@@ -324,7 +326,7 @@
 	array_create(&ibox->box.module_contexts,
 		     ibox->box.pool, sizeof(void *), 5);
 
-	index_flags = MAIL_INDEX_OPEN_FLAG_CREATE;
+	index_flags = move_to_memory ? 0 : MAIL_INDEX_OPEN_FLAG_CREATE;
 	if ((flags & MAILBOX_OPEN_FAST) != 0)
 		index_flags |= MAIL_INDEX_OPEN_FLAG_FAST;
 	if ((storage->flags & MAIL_STORAGE_FLAG_MMAP_DISABLE) != 0)
@@ -355,10 +357,18 @@
 	ibox->mail_read_mmaped = (storage->flags &
 				  MAIL_STORAGE_FLAG_MMAP_MAILS) != 0;
 
-	if (mail_index_open(index, index_flags, lock_method) < 0) {
-		mail_storage_set_index_error(ibox);
-		index_storage_mailbox_free(&ibox->box);
-		return -1;
+	ret = mail_index_open(index, index_flags, lock_method);
+	if (ret <= 0 || move_to_memory) {
+		if (mail_index_move_to_memory(index) < 0) {
+			/* try opening once more. it should be created
+			   directly into memory now. */
+			ret = mail_index_open(index, index_flags, lock_method);
+			if (ret <= 0) {
+				mail_storage_set_index_error(ibox);
+				index_storage_mailbox_free(&ibox->box);
+				return -1;
+			}
+		}
 	}
 
 	ibox->md5hdr_ext_idx =

Index: index-storage.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-storage.h,v
retrieving revision 1.98
retrieving revision 1.99
diff -u -d -r1.98 -r1.99
--- index-storage.h	18 Jan 2006 22:16:43 -0000	1.98
+++ index-storage.h	18 Jan 2006 23:14:44 -0000	1.99
@@ -114,7 +114,8 @@
 
 int index_storage_mailbox_init(struct index_mailbox *ibox,
 			       struct mail_index *index, const char *name,
-			       enum mailbox_open_flags flags);
+			       enum mailbox_open_flags flags,
+			       bool move_to_memory);
 void index_storage_mailbox_free(struct mailbox *box);
 
 bool index_storage_is_readonly(struct mailbox *box);



More information about the dovecot-cvs mailing list