dovecot: Check that header is still valid after syncing. If not,...
dovecot at dovecot.org
dovecot at dovecot.org
Sun Sep 2 03:07:26 EEST 2007
details: http://hg.dovecot.org/dovecot/rev/702f13f44c5e
changeset: 6342:702f13f44c5e
user: Timo Sirainen <tss at iki.fi>
date: Sun Sep 02 03:04:47 2007 +0300
description:
Check that header is still valid after syncing. If not, fsck.
diffstat:
3 files changed, 11 insertions(+), 2 deletions(-)
src/lib-index/mail-index-map.c | 4 ++--
src/lib-index/mail-index-private.h | 1 +
src/lib-index/mail-index-sync-update.c | 8 ++++++++
diffs (50 lines):
diff -r adffeec04dcc -r 702f13f44c5e src/lib-index/mail-index-map.c
--- a/src/lib-index/mail-index-map.c Sat Sep 01 03:14:11 2007 +0300
+++ b/src/lib-index/mail-index-map.c Sun Sep 02 03:04:47 2007 +0300
@@ -263,7 +263,7 @@ static bool mail_index_check_header_comp
return TRUE;
}
-static int mail_index_check_header(struct mail_index_map *map)
+int mail_index_map_check_header(struct mail_index_map *map)
{
struct mail_index *index = map->index;
const struct mail_index_header *hdr = &map->hdr;
@@ -684,7 +684,7 @@ static int mail_index_map_latest_file(st
}
if (ret > 0) {
/* make sure the header is ok before using this mapping */
- ret = mail_index_check_header(new_map);
+ ret = mail_index_map_check_header(new_map);
if (ret >= 0) {
ret = mail_index_parse_extensions(new_map);
if (ret > 0) {
diff -r adffeec04dcc -r 702f13f44c5e src/lib-index/mail-index-private.h
--- a/src/lib-index/mail-index-private.h Sat Sep 01 03:14:11 2007 +0300
+++ b/src/lib-index/mail-index-private.h Sun Sep 02 03:04:47 2007 +0300
@@ -289,6 +289,7 @@ const struct mail_index_ext *
const struct mail_index_ext *
mail_index_view_get_ext(struct mail_index_view *view, uint32_t ext_id);
+int mail_index_map_check_header(struct mail_index_map *map);
int mail_index_map_parse_keywords(struct mail_index_map *map);
void mail_index_view_transaction_ref(struct mail_index_view *view);
diff -r adffeec04dcc -r 702f13f44c5e src/lib-index/mail-index-sync-update.c
--- a/src/lib-index/mail-index-sync-update.c Sat Sep 01 03:14:11 2007 +0300
+++ b/src/lib-index/mail-index-sync-update.c Sun Sep 02 03:04:47 2007 +0300
@@ -821,6 +821,14 @@ int mail_index_sync_map(struct mail_inde
i_assert(index->map == map || type == MAIL_INDEX_SYNC_HANDLER_VIEW);
+ if (mail_index_map_check_header(map) <= 0) {
+ mail_index_set_error(index,
+ "Synchronization corrupted index header: %s",
+ index->filepath);
+ (void)mail_index_fsck(index);
+ map = index->map;
+ }
+
*_map = map;
return ret < 0 ? -1 : 1;
}
More information about the dovecot-cvs
mailing list