[dovecot-cvs] dovecot/src/lib-index mail-index-sync-update.c, 1.96.2.5, 1.96.2.6 mail-index-view.c, 1.44.2.2, 1.44.2.3

tss at dovecot.org tss at dovecot.org
Thu Dec 28 20:54:58 UTC 2006


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

Modified Files:
      Tag: branch_1_0
	mail-index-sync-update.c mail-index-view.c 
Log Message:
If there are transactions left while unlocking, don't unlock. Also added some
next_uid debugging.



Index: mail-index-sync-update.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-sync-update.c,v
retrieving revision 1.96.2.5
retrieving revision 1.96.2.6
diff -u -d -r1.96.2.5 -r1.96.2.6
--- mail-index-sync-update.c	23 Jul 2006 21:41:37 -0000	1.96.2.5
+++ mail-index-sync-update.c	28 Dec 2006 20:54:56 -0000	1.96.2.6
@@ -290,6 +290,7 @@
 	map->hdr.next_uid = rec->uid+1;
 	map->records_count++;
 	view->hdr.messages_count++;
+	view->hdr.next_uid = rec->uid+1;
 
 	write_seq_update(map, map->hdr.messages_count, map->hdr.messages_count);
 

Index: mail-index-view.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-view.c,v
retrieving revision 1.44.2.2
retrieving revision 1.44.2.3
diff -u -d -r1.44.2.2 -r1.44.2.3
--- mail-index-view.c	10 Dec 2006 14:43:19 -0000	1.44.2.2
+++ mail-index-view.c	28 Dec 2006 20:54:56 -0000	1.44.2.3
@@ -49,10 +49,26 @@
 	i_free(view);
 }
 
+#ifdef DEBUG
+static void mail_index_view_check_nextuid(struct mail_index_view *view)
+{
+	struct mail_index_record *rec;
+
+	if (view->hdr.messages_count == 0)
+		return;
+
+	rec = MAIL_INDEX_MAP_IDX(view->map, view->hdr.messages_count-1);
+	i_assert(rec->uid < view->hdr.next_uid);
+}
+#endif
+
 int mail_index_view_lock_head(struct mail_index_view *view, bool update_index)
 {
 	unsigned int lock_id;
 
+#ifdef DEBUG
+	mail_index_view_check_nextuid(view);
+#endif
 	if (MAIL_INDEX_MAP_IS_IN_MEMORY(view->index->map))
 		return 0;
 
@@ -91,6 +107,9 @@
 
 	if (view->map != view->index->map) {
 		/* not head mapping, no need to lock */
+#ifdef DEBUG
+		mail_index_view_check_nextuid(view);
+#endif
 		return 0;
 	}
 
@@ -99,7 +118,11 @@
 
 void mail_index_view_unlock(struct mail_index_view *view)
 {
-	if (view->lock_id != 0) {
+#ifdef DEBUG
+	mail_index_view_check_nextuid(view);
+#endif
+
+	if (view->lock_id != 0 && view->transactions == 0) {
 		mail_index_unlock(view->index, view->lock_id);
 		view->lock_id = 0;
 	}
@@ -458,6 +481,9 @@
 	if (--view->refcount > 0)
 		return;
 
+	i_assert(view->transactions == 0);
+
+	mail_index_view_unlock(view);
 	view->methods.close(view);
 }
 



More information about the dovecot-cvs mailing list