patch 8.2.3509: undo file is not synced

Problem:    Undo file is not synced. (Sami Farin)
Solution:   Sync the undo file if 'fsync' is set. (Christian Brabandt,
            closes #8879, closes #8920)
This commit is contained in:
Bram Moolenaar
2021-10-14 17:52:23 +01:00
parent 051a8a375f
commit 340dd0fbe4
3 changed files with 9 additions and 2 deletions

View 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 systems without an fsync() implementation, this variable is always
off. off.
Also see 'swapsync' for controlling fsync() on swap files. Also see 'swapsync' for controlling fsync() on swap files.
'fsync' also applies to |writefile()|, unless a flag is used to 'fsync' also applies to |writefile()| (unless a flag is used to
overrule it. overrule it) and when writing undo files (see |undo-persistence|).
This option cannot be set from a |modeline| or in the |sandbox|, for This option cannot be set from a |modeline| or in the |sandbox|, for
security reasons. security reasons.

View File

@ -1786,6 +1786,11 @@ u_write_undo(
write_ok = FALSE; write_ok = FALSE;
#endif #endif
#if defined(UNIX) && defined(HAVE_FSYNC)
if (p_fs && fflush(fp) == 0 && vim_fsync(fd) != 0)
write_ok = FALSE;
#endif
write_error: write_error:
fclose(fp); fclose(fp);
if (!write_ok) if (!write_ok)

View File

@ -757,6 +757,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
3509,
/**/ /**/
3508, 3508,
/**/ /**/