[dovecot-cvs] dovecot/src/lib-index mail-index-private.h, 1.67, 1.68 mail-index-sync-update.c, 1.93, 1.94 mail-index.c, 1.229, 1.230

tss-movial at dovecot.org tss-movial at dovecot.org
Tue May 2 14:04:33 EEST 2006


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

Modified Files:
	mail-index-private.h mail-index-sync-update.c mail-index.c 
Log Message:
mmap_disable: When syncing in-memory index from transaction log, we didn't
skip external transactions which were already been in our in-memory
mapping, causing "Append with UID n, but next_uid = m" errors.



Index: mail-index-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-private.h,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -d -r1.67 -r1.68
--- mail-index-private.h	26 Feb 2006 10:15:41 -0000	1.67
+++ mail-index-private.h	2 May 2006 11:04:30 -0000	1.68
@@ -8,6 +8,7 @@
 #include "mail-index.h"
 
 struct mail_transaction_header;
+struct mail_transaction_log_view;
 struct mail_index_sync_map_ctx;
 
 /* How many seconds to wait a lock for index file. */
@@ -251,6 +252,8 @@
 
 int mail_index_fix_header(struct mail_index *index, struct mail_index_map *map,
 			  struct mail_index_header *hdr, const char **error_r);
+bool mail_index_is_ext_synced(struct mail_transaction_log_view *log_view,
+			      struct mail_index_map *map);
 
 void mail_index_view_transaction_ref(struct mail_index_view *view);
 void mail_index_view_transaction_unref(struct mail_index_view *view);

Index: mail-index-sync-update.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-sync-update.c,v
retrieving revision 1.93
retrieving revision 1.94
diff -u -d -r1.93 -r1.94
--- mail-index-sync-update.c	17 Feb 2006 23:36:38 -0000	1.93
+++ mail-index-sync-update.c	2 May 2006 11:04:30 -0000	1.94
@@ -657,19 +657,8 @@
 				continue;
 			}
 		} else if (check_ext_offsets) {
-			uint32_t prev_seq;
-			uoff_t prev_offset;
-
-			mail_transaction_log_view_get_prev_pos(view->log_view,
-							       &prev_seq,
-							       &prev_offset);
-			if (prev_seq < view->map->hdr.log_file_seq ||
-			    (prev_seq == view->map->hdr.log_file_seq &&
-			     prev_offset <
-			     view->map->hdr.log_file_ext_offset)) {
-				/* we have already synced this change */
+			if (mail_index_is_ext_synced(view->log_view, view->map))
 				continue;
-			}
 			check_ext_offsets = FALSE;
 		}
 

Index: mail-index.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index.c,v
retrieving revision 1.229
retrieving revision 1.230
diff -u -d -r1.229 -r1.230
--- mail-index.c	25 Apr 2006 13:40:20 -0000	1.229
+++ mail-index.c	2 May 2006 11:04:30 -0000	1.230
@@ -781,6 +781,19 @@
 	return 1;
 }
 
+bool mail_index_is_ext_synced(struct mail_transaction_log_view *log_view,
+			      struct mail_index_map *map)
+{
+	uint32_t prev_seq;
+	uoff_t prev_offset;
+
+	mail_transaction_log_view_get_prev_pos(log_view, &prev_seq,
+					       &prev_offset);
+	return prev_seq < map->hdr.log_file_seq ||
+		(prev_seq == map->hdr.log_file_seq &&
+		 prev_offset < map->hdr.log_file_ext_offset);
+}
+
 static int mail_index_sync_from_transactions(struct mail_index *index,
 					     struct mail_index_map **map,
 					     bool sync_to_index)
@@ -796,7 +809,7 @@
 	uoff_t prev_offset, max_offset;
 	size_t pos;
 	int ret;
-	bool skipped;
+	bool skipped, check_ext_offsets;
 
 	if (sync_to_index) {
 		/* read the real log position where we are supposed to be
@@ -852,8 +865,16 @@
 	mail_index_sync_map_init(&sync_map_ctx, view,
 				 MAIL_INDEX_SYNC_HANDLER_VIEW);
 
+	check_ext_offsets = TRUE;
 	while ((ret = mail_transaction_log_view_next(log_view, &thdr, &tdata,
 						     &skipped)) > 0) {
+		if ((thdr->type & MAIL_TRANSACTION_EXTERNAL) != 0 &&
+		    check_ext_offsets) {
+			if (mail_index_is_ext_synced(log_view, index->map))
+				continue;
+			check_ext_offsets = FALSE;
+		}
+
 		if (mail_index_sync_record(&sync_map_ctx, thdr, tdata) < 0) {
 			ret = -1;
 			break;



More information about the dovecot-cvs mailing list