From: Timo Sirainen Date: Tue, 11 Nov 2003 16:36:59 +0000 (+0200) Subject: Fixed "LF not found where expected" error happening in some conditions. X-Git-Tag: 1.1.alpha1~4224 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e6dd04548a516eac2ff1179229ec0abfe38f3fc5;p=thirdparty%2Fdovecot%2Fcore.git Fixed "LF not found where expected" error happening in some conditions. --HG-- branch : HEAD --- diff --git a/src/lib-index/mbox/mbox-append.c b/src/lib-index/mbox/mbox-append.c index 64d82685af..685b78893b 100644 --- a/src/lib-index/mbox/mbox-append.c +++ b/src/lib-index/mbox/mbox-append.c @@ -182,10 +182,10 @@ int mbox_index_append_stream(struct mail_index *index, struct istream *input) int ret; if (!index->set_lock(index, MAIL_LOCK_EXCLUSIVE)) - return FALSE; + return -1; if (mail_cache_transaction_begin(index->cache, TRUE, &trans_ctx) <= 0) - return FALSE; + return -1; do { offset = input->v_offset; @@ -234,5 +234,5 @@ int mbox_index_append_stream(struct mail_index *index, struct istream *input) if (!mail_cache_transaction_end(trans_ctx)) ret = -1; - return ret >= 0; + return ret; } diff --git a/src/lib-index/mbox/mbox-sync-full.c b/src/lib-index/mbox/mbox-sync-full.c index e81c0431ba..3aa7f5af53 100644 --- a/src/lib-index/mbox/mbox-sync-full.c +++ b/src/lib-index/mbox/mbox-sync-full.c @@ -214,7 +214,7 @@ static int mbox_sync_from_stream(struct mail_index *index, int dirty, ret; if (mail_cache_lock(index->cache, FALSE) <= 0) - return FALSE; + return -1; mail_cache_unlock_later(index->cache); mbox_skip_empty_lines(input); @@ -225,7 +225,7 @@ static int mbox_sync_from_stream(struct mail_index *index, memcmp(data, "From ", 5) != 0) { index_set_error(index, "File isn't in mbox format: %s", index->mailbox_path); - return FALSE; + return -1; } /* we'll go through the mailbox and index in order matching the @@ -252,7 +252,7 @@ static int mbox_sync_from_stream(struct mail_index *index, "Error syncing mbox file %s: " "LF not found where expected", index->mailbox_path); - return FALSE; + return -1; } } @@ -260,7 +260,7 @@ static int mbox_sync_from_stream(struct mail_index *index, if (ret < 0) { if (input->eof) break; - return FALSE; + return -1; } if (ret == 0) { @@ -273,7 +273,7 @@ static int mbox_sync_from_stream(struct mail_index *index, if (rec != NULL) { if (!index->expunge(index, rec, INDEX_END_RECORD(index)-1, seq, index->header->messages_count, TRUE)) - return FALSE; + return -1; } if (!dirty && @@ -283,7 +283,7 @@ static int mbox_sync_from_stream(struct mail_index *index, } if ((index->set_flags & MAIL_INDEX_HDR_FLAG_REBUILD)) - return TRUE; + return 1; else return mbox_index_append_stream(index, input); } @@ -293,7 +293,7 @@ int mbox_sync_full(struct mail_index *index) struct istream *input; struct stat orig_st, st; uoff_t continue_offset; - int failed; + int ret, failed; i_assert(index->lock_type == MAIL_LOCK_EXCLUSIVE); @@ -306,8 +306,9 @@ int mbox_sync_full(struct mail_index *index) continue_offset = (uoff_t)-1; failed = TRUE; } else { - failed = !mbox_sync_from_stream(index, input); - continue_offset = failed || input->eof || + ret = mbox_sync_from_stream(index, input); + failed = ret < 0; + continue_offset = ret != 0 || (index->set_flags & MAIL_INDEX_HDR_FLAG_REBUILD) ? (uoff_t)-1 : input->v_offset; i_stream_unref(input); @@ -333,14 +334,14 @@ int mbox_sync_full(struct mail_index *index) i_stream_seek(input, continue_offset); failed = !mbox_index_append_stream(index, input); } else { - failed = !mbox_sync_from_stream(index, input); + failed = mbox_sync_from_stream(index, input) <= 0; } if (index->mbox_rewritten) { /* rewritten, sync again */ index->mbox_rewritten = FALSE; i_stream_seek(input, 0); - failed = !mbox_sync_from_stream(index, input); + failed = mbox_sync_from_stream(index, input) <= 0; } i_stream_unref(input);