dovecot-2.0: Changed some index error handling conditions to log...
dovecot at dovecot.org
dovecot at dovecot.org
Tue May 25 17:27:32 EEST 2010
details: http://hg.dovecot.org/dovecot-2.0/rev/6d68b7b25ae7
changeset: 11364:6d68b7b25ae7
user: Timo Sirainen <tss at iki.fi>
date: Tue May 25 15:27:26 2010 +0100
description:
Changed some index error handling conditions to log an error instead of assert-crash.
diffstat:
src/lib-index/mail-transaction-log-file.c | 9 +++++++++
src/lib-index/mail-transaction-log-view.c | 10 ++++++++++
src/lib-storage/index/index-sync.c | 9 +++++++--
3 files changed, 26 insertions(+), 2 deletions(-)
diffs (65 lines):
diff -r b08abace44ed -r 6d68b7b25ae7 src/lib-index/mail-transaction-log-file.c
--- a/src/lib-index/mail-transaction-log-file.c Tue May 25 15:25:01 2010 +0100
+++ b/src/lib-index/mail-transaction-log-file.c Tue May 25 15:27:26 2010 +0100
@@ -192,6 +192,7 @@
struct mail_transaction_log_header *hdr)
{
struct mail_index *index = log->index;
+ struct mail_transaction_log_file *file;
memset(hdr, 0, sizeof(*hdr));
hdr->major_version = MAIL_TRANSACTION_LOG_MAJOR_VERSION;
@@ -226,6 +227,14 @@
}
if (log->head != NULL) {
+ /* make sure the sequence always increases to avoid crashes
+ later. this catches the buggy case where two processes
+ happen to replace the same log file. */
+ for (file = log->head->next; file != NULL; file = file->next) {
+ if (hdr->file_seq <= file->hdr.file_seq)
+ hdr->file_seq = file->hdr.file_seq + 1;
+ }
+
if (hdr->file_seq <= log->head->hdr.file_seq) {
/* make sure the sequence grows */
hdr->file_seq = log->head->hdr.file_seq+1;
diff -r b08abace44ed -r 6d68b7b25ae7 src/lib-index/mail-transaction-log-view.c
--- a/src/lib-index/mail-transaction-log-view.c Tue May 25 15:25:01 2010 +0100
+++ b/src/lib-index/mail-transaction-log-view.c Tue May 25 15:27:26 2010 +0100
@@ -202,6 +202,16 @@
}
i_assert(min_file_offset >= view->tail->hdr.hdr_size);
+ if (min_file_seq == view->head->hdr.file_seq &&
+ min_file_offset > view->head->sync_offset) {
+ /* log file offset is probably corrupted in the index file. */
+ mail_transaction_log_view_set_corrupted(view,
+ "file_seq=%u, min_file_offset (%"PRIuUOFF_T
+ ") > sync_offset (%"PRIuUOFF_T")", min_file_seq,
+ min_file_offset, view->head->sync_offset);
+ return -1;
+ }
+
/* we have all of them. update refcounts. */
mail_transaction_log_view_unref_all(view);
diff -r b08abace44ed -r 6d68b7b25ae7 src/lib-storage/index/index-sync.c
--- a/src/lib-storage/index/index-sync.c Tue May 25 15:25:01 2010 +0100
+++ b/src/lib-storage/index/index-sync.c Tue May 25 15:27:26 2010 +0100
@@ -37,8 +37,13 @@
struct index_mailbox_context *ibox = INDEX_STORAGE_CONTEXT(box);
if (uid <= ibox->recent_flags_prev_uid) {
- i_assert(seq_range_exists(&ibox->recent_flags, uid));
- return;
+ if (seq_range_exists(&ibox->recent_flags, uid))
+ return;
+
+ mail_storage_set_critical(box->storage,
+ "Recent flags state corrupted for mailbox %s",
+ box->vname);
+ array_clear(&ibox->recent_flags);
}
ibox->recent_flags_prev_uid = uid;
More information about the dovecot-cvs
mailing list