]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
fsync() saved mails
authorTimo Sirainen <tss@iki.fi>
Mon, 21 Apr 2003 15:41:19 +0000 (18:41 +0300)
committerTimo Sirainen <tss@iki.fi>
Mon, 21 Apr 2003 15:41:19 +0000 (18:41 +0300)
--HG--
branch : HEAD

src/lib-storage/index/maildir/maildir-save.c
src/lib-storage/index/mbox/mbox-save.c

index 7cdbb53e2485689eb62fed87c334ac62e13b578f..a9fcdf28eafe29cc28942bf245518056d51eecdd 100644 (file)
@@ -53,8 +53,18 @@ maildir_read_into_tmp(struct index_mailbox *ibox, const char *dir,
                fname = NULL;
 
        o_stream_unref(output);
-       if (close(fd) < 0)
+       /* FIXME: when saving multiple messages, we could get better
+          performance if we left the fd open and fsync()ed it later */
+       if (fsync(fd) < 0) {
+               mail_storage_set_critical(ibox->box.storage,
+                                         "fsync() failed for %s: %m", path);
                fname = NULL;
+       }
+       if (close(fd) < 0) {
+               mail_storage_set_critical(ibox->box.storage,
+                                         "close() failed for %s: %m", path);
+               fname = NULL;
+       }
 
        if (fname == NULL)
                (void)unlink(path);
index a7990e342d9d57545d2ded1645676df3b6d1c50d..f1a149413416ae51ea7ec3579aad22391222fdd8 100644 (file)
@@ -357,6 +357,11 @@ int mbox_storage_save_deinit(struct mail_save_context *ctx, int rollback)
                        syscall_error(ctx, "ftruncate()");
                        failed = TRUE;
                }
+       } else {
+               if (fdatasync(ctx->ibox->index->mbox_fd) < 0) {
+                       syscall_error(ctx, "fsync()");
+                       failed = TRUE;
+               }
        }
 
        i_free(ctx);