changeset 20709:c2b0657d69df

lib-index: mail_index_modseq_get_next_log_offset() shouldn't return offset beyond view's head This also allows removing the same workaround from dsync code.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Thu, 08 Sep 2016 22:08:11 +0300
parents f013cf80c12c
children bf222c46b4e9
files src/doveadm/dsync/dsync-transaction-log-scan.c src/lib-index/mail-index-modseq.c
diffstat 2 files changed, 14 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/doveadm/dsync/dsync-transaction-log-scan.c	Wed Sep 07 11:52:00 2016 +0300
+++ b/src/doveadm/dsync/dsync-transaction-log-scan.c	Thu Sep 08 22:08:11 2016 +0300
@@ -362,13 +362,7 @@
 						  &log_seq, &log_offset)) {
 		/* scan the view only up to end of the current view.
 		   if there are more changes, we don't care about them until
-		   the next sync. the modseq may however already point to
-		   beyond the current view's end (FIXME: why?) */
-		if (log_seq > end_seq ||
-		    (log_seq == end_seq && log_offset > end_offset)) {
-			end_seq = log_seq;
-			end_offset = log_offset;
-		}
+		   the next sync. */
 		ret = mail_transaction_log_view_set(log_view,
 						    log_seq, log_offset,
 						    end_seq, end_offset,
--- a/src/lib-index/mail-index-modseq.c	Wed Sep 07 11:52:00 2016 +0300
+++ b/src/lib-index/mail-index-modseq.c	Thu Sep 08 22:08:11 2016 +0300
@@ -722,6 +722,17 @@
 	}
 
 	*log_seq_r = prev_file->hdr.file_seq;
-	return mail_transaction_log_file_get_modseq_next_offset(
-					prev_file, modseq, log_offset_r) == 0;
+	if (mail_transaction_log_file_get_modseq_next_offset(prev_file, modseq,
+							     log_offset_r) < 0)
+		return FALSE;
+
+	if (*log_seq_r > view->log_file_head_seq ||
+	    (*log_seq_r == view->log_file_head_seq &&
+	     *log_offset_r > view->log_file_head_offset)) {
+		/* modseq is already beyond our view. move it back so the
+		   caller won't be confused. */
+		*log_seq_r = view->log_file_head_seq;
+		*log_offset_r = view->log_file_head_offset;
+	}
+	return TRUE;
 }