dovecot-1.3: dbox: Flush file input caches when needed so that w...

dovecot at dovecot.org dovecot at dovecot.org
Sat Apr 11 01:50:40 EEST 2009


details:   http://hg.dovecot.org/dovecot-1.3/rev/c957575afd8a
changeset: 9069:c957575afd8a
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Apr 10 18:38:36 2009 -0400
description:
dbox: Flush file input caches when needed so that we don't try to use partially written mails.

diffstat:

3 files changed, 19 insertions(+)
src/lib-storage/index/dbox/dbox-file.c |   12 ++++++++++++
src/lib-storage/index/dbox/dbox-file.h |    2 ++
src/lib-storage/index/dbox/dbox-map.c  |    5 +++++

diffs (49 lines):

diff -r b7142ab35480 -r c957575afd8a src/lib-storage/index/dbox/dbox-file.c
--- a/src/lib-storage/index/dbox/dbox-file.c	Fri Apr 10 18:27:02 2009 -0400
+++ b/src/lib-storage/index/dbox/dbox-file.c	Fri Apr 10 18:38:36 2009 -0400
@@ -95,6 +95,18 @@ void dbox_files_free(struct dbox_storage
 	for (i = 0; i < count; i++)
 		dbox_file_free(files[i]);
 	array_clear(&storage->open_files);
+}
+
+void dbox_files_sync_input(struct dbox_storage *storage)
+{
+	struct dbox_file *const *files;
+	unsigned int i, count;
+
+	files = array_get(&storage->open_files, &count);
+	for (i = 0; i < count; i++) {
+		if (files[i]->input != NULL)
+			i_stream_sync(files[i]->input);
+	}
 }
 
 static void
diff -r b7142ab35480 -r c957575afd8a src/lib-storage/index/dbox/dbox-file.h
--- a/src/lib-storage/index/dbox/dbox-file.h	Fri Apr 10 18:27:02 2009 -0400
+++ b/src/lib-storage/index/dbox/dbox-file.h	Fri Apr 10 18:38:36 2009 -0400
@@ -127,6 +127,8 @@ void dbox_file_unref(struct dbox_file **
 
 /* Free all currently opened files. */
 void dbox_files_free(struct dbox_storage *storage);
+/* Flush all cached input data from opened files. */
+void dbox_files_sync_input(struct dbox_storage *storage);
 
 /* Assign a newly created file a new id. For single files assign UID,
    for multi files assign map UID. */
diff -r b7142ab35480 -r c957575afd8a src/lib-storage/index/dbox/dbox-map.c
--- a/src/lib-storage/index/dbox/dbox-map.c	Fri Apr 10 18:27:02 2009 -0400
+++ b/src/lib-storage/index/dbox/dbox-map.c	Fri Apr 10 18:38:36 2009 -0400
@@ -120,6 +120,11 @@ int dbox_map_refresh(struct dbox_map *ma
 {
 	struct mail_index_view_sync_ctx *ctx;
 	bool delayed_expunges;
+
+	/* some open files may have read partially written mails. now that
+	   map syncing makes the new mails visible, we need to make sure the
+	   partial data is flushed out of memory */
+	dbox_files_sync_input(map->storage);
 
 	if (mail_index_refresh(map->view->index) < 0) {
 		mail_storage_set_internal_error(&map->storage->storage);


More information about the dovecot-cvs mailing list