[dovecot-cvs] dovecot/src/lib-storage/index index-storage.c, 1.85.2.5, 1.85.2.6 index-storage.h, 1.101.2.1, 1.101.2.2

tss at dovecot.org tss at dovecot.org
Thu Feb 22 13:37:37 UTC 2007


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

Modified Files:
      Tag: branch_1_0
	index-storage.c index-storage.h 
Log Message:
When using KEEP_LOCK, the mbox/uidlist file must be locked before index file
is opened. Otherwise we can end up in a deadlock.



Index: index-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-storage.c,v
retrieving revision 1.85.2.5
retrieving revision 1.85.2.6
diff -u -d -r1.85.2.5 -r1.85.2.6
--- index-storage.c	28 Dec 2006 16:27:42 -0000	1.85.2.5
+++ index-storage.c	22 Feb 2007 13:37:32 -0000	1.85.2.6
@@ -309,10 +309,9 @@
 	ibox->last_notify_type = MAILBOX_LOCK_NOTIFY_NONE;
 }
 
-int index_storage_mailbox_init(struct index_mailbox *ibox,
-			       struct mail_index *index, const char *name,
-			       enum mailbox_open_flags flags,
-			       bool move_to_memory)
+void index_storage_mailbox_init(struct index_mailbox *ibox, const char *name,
+				enum mailbox_open_flags flags,
+				bool move_to_memory)
 {
 	struct mail_storage *storage = &ibox->storage->storage;
 	enum mail_index_open_flags index_flags;
@@ -352,35 +351,31 @@
 	ibox->readonly = (flags & MAILBOX_OPEN_READONLY) != 0;
 	ibox->keep_recent = (flags & MAILBOX_OPEN_KEEP_RECENT) != 0;
 	ibox->keep_locked = (flags & MAILBOX_OPEN_KEEP_LOCKED) != 0;
-	ibox->index = index;
 
 	ibox->next_lock_notify = time(NULL) + LOCK_NOTIFY_INTERVAL;
 	ibox->commit_log_file_seq = 0;
 	ibox->mail_read_mmaped = (storage->flags &
 				  MAIL_STORAGE_FLAG_MMAP_MAILS) != 0;
 
-	ret = mail_index_open(index, index_flags, lock_method);
+	ret = mail_index_open(ibox->index, index_flags, lock_method);
 	if (ret <= 0 || move_to_memory) {
-		if (mail_index_move_to_memory(index) < 0) {
+		if (mail_index_move_to_memory(ibox->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;
-			}
+			ret = mail_index_open(ibox->index, index_flags,
+					      lock_method);
+			if (ret <= 0)
+				i_panic("in-memory index creation failed");
 		}
 	}
 
 	ibox->md5hdr_ext_idx =
-		mail_index_ext_register(index, "header-md5", 0, 16, 1);
+		mail_index_ext_register(ibox->index, "header-md5", 0, 16, 1);
 
-	ibox->cache = mail_index_get_cache(index);
+	ibox->cache = mail_index_get_cache(ibox->index);
 	index_cache_register_defaults(ibox);
-	ibox->view = mail_index_view_open(index);
-	ibox->keyword_names = mail_index_get_keywords(index);
-	return 0;
+	ibox->view = mail_index_view_open(ibox->index);
+	ibox->keyword_names = mail_index_get_keywords(ibox->index);
 }
 
 void index_storage_mailbox_free(struct mailbox *box)

Index: index-storage.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-storage.h,v
retrieving revision 1.101.2.1
retrieving revision 1.101.2.2
diff -u -d -r1.101.2.1 -r1.101.2.2
--- index-storage.h	7 Aug 2006 12:42:25 -0000	1.101.2.1
+++ index-storage.h	22 Feb 2007 13:37:32 -0000	1.101.2.2
@@ -114,10 +114,9 @@
 			enum mail_storage_lock_method lock_method);
 void index_storage_deinit(struct index_storage *storage);
 
-int index_storage_mailbox_init(struct index_mailbox *ibox,
-			       struct mail_index *index, const char *name,
-			       enum mailbox_open_flags flags,
-			       bool move_to_memory);
+void index_storage_mailbox_init(struct index_mailbox *ibox, const char *name,
+				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