changeset 9433:6c6460531514 HEAD

lib-index: Give nicer error if index's log position suddenly goes backwards.
author Timo Sirainen <tss@iki.fi>
date Thu, 15 Oct 2009 15:56:06 -0400
parents 439e14ff1467
children 373b22cbabac
files src/lib-index/mail-index-view-sync.c
diffstat 1 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-index-view-sync.c	Thu Oct 15 13:51:00 2009 -0400
+++ b/src/lib-index/mail-index-view-sync.c	Thu Oct 15 15:56:06 2009 -0400
@@ -55,6 +55,17 @@
 	end_seq = hdr->log_file_seq;
 	end_offset = hdr->log_file_head_offset;
 
+	if (end_seq < view->log_file_head_seq ||
+	    (end_seq == view->log_file_head_seq &&
+	     end_offset < view->log_file_head_offset)) {
+		mail_index_set_error(view->index,
+			"%s log position went backwards "
+			"(%u,%"PRIuUOFF_T" < %u,%"PRIuUOFF_T")",
+			view->index->filepath, end_seq, end_offset,
+			view->log_file_head_seq, view->log_file_head_offset);
+		return -1;
+	}
+
 	for (;;) {
 		/* the view begins from the first non-synced transaction */
 		ret = mail_transaction_log_view_set(view->log_view,