From: Timo Sirainen Date: Thu, 8 Sep 2016 19:08:11 +0000 (+0300) Subject: lib-index: mail_index_modseq_get_next_log_offset() shouldn't return offset beyond... X-Git-Tag: 2.2.26~292 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=54ee447f75cd2cca9cd7507d81cad201606c5de0;p=thirdparty%2Fdovecot%2Fcore.git 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. --- diff --git a/src/doveadm/dsync/dsync-transaction-log-scan.c b/src/doveadm/dsync/dsync-transaction-log-scan.c index f39d2c48a7..8fc8a99e66 100644 --- a/src/doveadm/dsync/dsync-transaction-log-scan.c +++ b/src/doveadm/dsync/dsync-transaction-log-scan.c @@ -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, diff --git a/src/lib-index/mail-index-modseq.c b/src/lib-index/mail-index-modseq.c index 29ceb585d5..eeb85de119 100644 --- a/src/lib-index/mail-index-modseq.c +++ b/src/lib-index/mail-index-modseq.c @@ -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; }