Mercurial > dovecot > original-hg > dovecot-1.2
changeset 3393:2e7359e17b4c HEAD
Call i_stream_sync() a bit more often, especially before checking file size
to make sure it's not cached. Changed an assert to critical error.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 28 May 2005 14:18:49 +0300 |
parents | e8c0736ec5be |
children | 30099e1ccf97 |
files | src/lib-storage/index/mbox/mbox-sync-rewrite.c src/lib-storage/index/mbox/mbox-sync.c |
diffstat | 2 files changed, 12 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/mbox/mbox-sync-rewrite.c Wed May 25 14:39:57 2005 +0300 +++ b/src/lib-storage/index/mbox/mbox-sync-rewrite.c Sat May 28 14:18:49 2005 +0300 @@ -47,6 +47,7 @@ "o_stream_send_istream()"); } + i_stream_sync(sync_ctx->input); o_stream_unref(output); return (int)ret; }
--- a/src/lib-storage/index/mbox/mbox-sync.c Wed May 25 14:39:57 2005 +0300 +++ b/src/lib-storage/index/mbox/mbox-sync.c Sat May 28 14:18:49 2005 +0300 @@ -1155,14 +1155,23 @@ return 0; } + /* make sure i_stream_stat() doesn't try to use cached file size */ + i_stream_sync(sync_ctx->file_input); + st = i_stream_stat(sync_ctx->file_input); if (st == NULL) { mbox_set_syscall_error(sync_ctx->mbox, "i_stream_stat()"); return -1; } - file_size = st->st_size; - i_assert(file_size >= sync_ctx->file_input->v_offset); + if (file_size < sync_ctx->file_input->v_offset) { + mail_storage_set_critical(STORAGE(sync_ctx->mbox->storage), + "file size unexpectedly shrinked in mbox file %s " + "(%"PRIuUOFF_T" vs %"PRIuUOFF_T")", + sync_ctx->mbox->path, file_size, + sync_ctx->file_input->v_offset); + return -1; + } trailer_size = file_size - sync_ctx->file_input->v_offset; i_assert(trailer_size <= 1);