[dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-sync-rewrite.c, 1.51, 1.52 mbox-sync.c, 1.161, 1.162

cras at dovecot.org cras at dovecot.org
Sat May 28 14:18:52 EEST 2005


Update of /var/lib/cvs/dovecot/src/lib-storage/index/mbox
In directory talvi:/tmp/cvs-serv4960

Modified Files:
	mbox-sync-rewrite.c mbox-sync.c 
Log Message:
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.



Index: mbox-sync-rewrite.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-sync-rewrite.c,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -d -r1.51 -r1.52
--- mbox-sync-rewrite.c	14 May 2005 14:01:03 -0000	1.51
+++ mbox-sync-rewrite.c	28 May 2005 11:18:49 -0000	1.52
@@ -47,6 +47,7 @@
 				       "o_stream_send_istream()");
 	}
 
+	i_stream_sync(sync_ctx->input);
 	o_stream_unref(output);
 	return (int)ret;
 }

Index: mbox-sync.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-sync.c,v
retrieving revision 1.161
retrieving revision 1.162
diff -u -d -r1.161 -r1.162
--- mbox-sync.c	14 May 2005 17:17:29 -0000	1.161
+++ mbox-sync.c	28 May 2005 11:18:49 -0000	1.162
@@ -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);
 



More information about the dovecot-cvs mailing list