]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
dbox: Flush file input caches when needed so that we don't try to use partially writt...
authorTimo Sirainen <tss@iki.fi>
Fri, 10 Apr 2009 22:38:36 +0000 (18:38 -0400)
committerTimo Sirainen <tss@iki.fi>
Fri, 10 Apr 2009 22:38:36 +0000 (18:38 -0400)
--HG--
branch : HEAD

src/lib-storage/index/dbox/dbox-file.c
src/lib-storage/index/dbox/dbox-file.h
src/lib-storage/index/dbox/dbox-map.c

index 44234d3592782a63856ddab8a2e557d6ac56e6b7..6acb33da131126a35e01d5982838846ca7db313a 100644 (file)
@@ -97,6 +97,18 @@ void dbox_files_free(struct dbox_storage *storage)
        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
 dbox_close_open_files(struct dbox_storage *storage, unsigned int close_count)
 {
index b36dc65b624a33477daa80cd9d56d6e0c3ec8c96..d0c18637c4ab17a75f1ba9436bc996e1521e92cc 100644 (file)
@@ -127,6 +127,8 @@ void dbox_file_unref(struct dbox_file **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. */
index 9dd2ff6657802e6f5fbe98e89ac3d3459139ac94..981e3ee722dcaa82614a9cd18c1fb3fbb9adff0b 100644 (file)
@@ -121,6 +121,11 @@ int dbox_map_refresh(struct dbox_map *map)
        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);
                mail_index_reset_error(map->index);