dovecot: Handle corruption marking by unlinking dovecot.index fi...

dovecot at dovecot.org dovecot at dovecot.org
Tue Jun 19 15:26:50 EEST 2007


details:   http://hg.dovecot.org/dovecot/rev/98d5e3bd4d13
changeset: 5775:98d5e3bd4d13
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Jun 19 15:26:47 2007 +0300
description:
Handle corruption marking by unlinking dovecot.index file. Removed
mail_index_write_base_header().

diffstat:

2 files changed, 2 insertions(+), 31 deletions(-)
src/lib-index/mail-index-private.h |    3 ---
src/lib-index/mail-index.c         |   30 ++----------------------------

diffs (61 lines):

diff -r 1af7024361e9 -r 98d5e3bd4d13 src/lib-index/mail-index-private.h
--- a/src/lib-index/mail-index-private.h	Tue Jun 19 15:23:18 2007 +0300
+++ b/src/lib-index/mail-index-private.h	Tue Jun 19 15:26:47 2007 +0300
@@ -211,9 +211,6 @@ void mail_index_unregister_sync_lost_han
 void mail_index_unregister_sync_lost_handler(struct mail_index *index,
 					mail_index_sync_lost_handler_t *cb);
 
-int mail_index_write_base_header(struct mail_index *index,
-				 const struct mail_index_header *hdr);
-
 int mail_index_create_tmp_file(struct mail_index *index, const char **path_r);
 
 int mail_index_try_open_only(struct mail_index *index);
diff -r 1af7024361e9 -r 98d5e3bd4d13 src/lib-index/mail-index.c
--- a/src/lib-index/mail-index.c	Tue Jun 19 15:23:18 2007 +0300
+++ b/src/lib-index/mail-index.c	Tue Jun 19 15:26:47 2007 +0300
@@ -368,27 +368,6 @@ mail_index_try_open(struct mail_index *i
 		index->fd = -1;
 	}
 	return ret;
-}
-
-int mail_index_write_base_header(struct mail_index *index,
-				 const struct mail_index_header *hdr)
-{
-	size_t hdr_size;
-
-	// FIXME: this whole function should go away
-	if (index->fd == -1)
-		return -1;
-
-	hdr_size = I_MIN(sizeof(*hdr), hdr->base_header_size);
-
-	if (pwrite_full(index->fd, hdr, hdr_size, 0) < 0) {
-		mail_index_set_syscall_error(index, "pwrite_full()");
-		return -1;
-	}
-
-	index->map->hdr = *hdr;
-	buffer_write(index->map->hdr_copy_buf, 0, hdr, hdr_size);
-	return 0;
 }
 
 int mail_index_create_tmp_file(struct mail_index *index, const char **path_r)
@@ -680,14 +659,9 @@ void mail_index_mark_corrupted(struct ma
 {
 	mail_index_set_inconsistent(index);
 
-	if (index->readonly || index->map == NULL)
-		return;
-
 	index->map->hdr.flags |= MAIL_INDEX_HDR_FLAG_CORRUPTED;
-	if (mail_index_write_base_header(index, &index->map->hdr) == 0) {
-		if (!MAIL_INDEX_IS_IN_MEMORY(index) && fsync(index->fd) < 0)
-			mail_index_set_syscall_error(index, "fsync()");
-	}
+	if (unlink(index->filepath) < 0 && errno != ENOENT && errno != ESTALE)
+		mail_index_set_syscall_error(index, "unlink()");
 }
 
 int mail_index_set_syscall_error(struct mail_index *index,


More information about the dovecot-cvs mailing list