]> granicus.if.org Git - vim/commitdiff
patch 8.2.3509: undo file is not synced v8.2.3509
authorBram Moolenaar <Bram@vim.org>
Thu, 14 Oct 2021 16:52:23 +0000 (17:52 +0100)
committerBram Moolenaar <Bram@vim.org>
Thu, 14 Oct 2021 16:52:23 +0000 (17:52 +0100)
Problem:    Undo file is not synced. (Sami Farin)
Solution:   Sync the undo file if 'fsync' is set. (Christian Brabandt,
            closes #8879, closes #8920)

runtime/doc/options.txt
src/undo.c
src/version.c

index 6bf0a5820caabf9d1ec0b2c8120aabd5a82bf80d..91df5df2e7ff08cc3a5a7cc8ff298aa5b26775a4 100644 (file)
@@ -3610,8 +3610,8 @@ A jump table for the options with a short description can be found at |Q_op|.
        systems without an fsync() implementation, this variable is always
        off.
        Also see 'swapsync' for controlling fsync() on swap files.
-       'fsync' also applies to |writefile()|unless a flag is used to
-       overrule it.
+       'fsync' also applies to |writefile()| (unless a flag is used to
+       overrule it) and when writing undo files (see |undo-persistence|).
        This option cannot be set from a |modeline| or in the |sandbox|, for
        security reasons.
 
index 814130108e731712cf9d731159cf1e023a6ce335..033fa6ea0d8fe99d36ff7b43b82197b48af32727 100644 (file)
@@ -1786,6 +1786,11 @@ u_write_undo(
        write_ok = FALSE;
 #endif
 
+#if defined(UNIX) && defined(HAVE_FSYNC)
+    if (p_fs && fflush(fp) == 0 && vim_fsync(fd) != 0)
+       write_ok = FALSE;
+#endif
+
 write_error:
     fclose(fp);
     if (!write_ok)
index 2125972bbf5e037cded682112ddac40fca273cd7..31f00157b3c9939af0afe88d526289133e5ba556 100644 (file)
@@ -757,6 +757,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3509,
 /**/
     3508,
 /**/