]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: mail_index_modseq_get_next_log_offset() shouldn't return offset beyond...
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 8 Sep 2016 19:08:11 +0000 (22:08 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 9 Sep 2016 11:23:07 +0000 (14:23 +0300)
This also allows removing the same workaround from dsync code.

src/doveadm/dsync/dsync-transaction-log-scan.c
src/lib-index/mail-index-modseq.c

index f39d2c48a7c2b025239836413fd52091255a91ec..8fc8a99e663e9799ee91cf1e3c0e3aa7a2202144 100644 (file)
@@ -362,13 +362,7 @@ dsync_log_set(struct dsync_transaction_log_scan *ctx,
                                                  &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,
index 29ceb585d5304f05eeb32275127c4414eabeb4bb..eeb85de119a7719fba02b34b09787484b76a0d0f 100644 (file)
@@ -722,6 +722,17 @@ bool mail_index_modseq_get_next_log_offset(struct mail_index_view *view,
        }
 
        *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;
 }