Mercurial > dovecot > original-hg > dovecot-1.2
changeset 5775:98d5e3bd4d13 HEAD
Handle corruption marking by unlinking dovecot.index file. Removed
mail_index_write_base_header().
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 19 Jun 2007 15:26:47 +0300 |
parents | 1af7024361e9 |
children | 5ce403e0ef56 |
files | src/lib-index/mail-index-private.h src/lib-index/mail-index.c |
diffstat | 2 files changed, 2 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- 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_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);
--- 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 @@ -370,27 +370,6 @@ 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) { mode_t old_mask; @@ -680,14 +659,9 @@ { 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,