aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/os/fileio.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2017-04-01 22:38:21 +0200
committerGitHub <noreply@github.com>2017-04-01 22:38:20 +0200
commit518f28f537971c70d7781ce30c5de0c829e01464 (patch)
tree9c76363156ee48433f1f213437320b7bcf45704e /src/nvim/os/fileio.c
parent337b6179df852350b52409fd3806e4b47ab2875b (diff)
parent19690d4a25f15dfa752ac3723384f1d33f06329a (diff)
downloadrneovim-518f28f537971c70d7781ce30c5de0c829e01464.tar.gz
rneovim-518f28f537971c70d7781ce30c5de0c829e01464.tar.bz2
rneovim-518f28f537971c70d7781ce30c5de0c829e01464.zip
Merge #6422 from ZyX-I/fix-6420
eval,fileio: Omit additional fsync() call
Diffstat (limited to 'src/nvim/os/fileio.c')
-rw-r--r--src/nvim/os/fileio.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/src/nvim/os/fileio.c b/src/nvim/os/fileio.c
index 775f2bd449..3c928363cc 100644
--- a/src/nvim/os/fileio.c
+++ b/src/nvim/os/fileio.c
@@ -143,21 +143,36 @@ int file_free(FileDescriptor *const fp) FUNC_ATTR_NONNULL_ALL
/// @param[in,out] fp File to work with.
///
/// @return 0 or error code.
-int file_fsync(FileDescriptor *const fp)
+int file_flush(FileDescriptor *const fp)
FUNC_ATTR_NONNULL_ALL
{
if (!fp->wr) {
return 0;
}
file_rb_write_full_cb(fp->rv, fp);
- if (fp->_error != 0) {
- const int error = fp->_error;
- fp->_error = 0;
- return error;
+ const int error = fp->_error;
+ fp->_error = 0;
+ return error;
+}
+
+/// Flush file modifications to disk and run fsync()
+///
+/// @param[in,out] fp File to work with.
+///
+/// @return 0 or error code.
+int file_fsync(FileDescriptor *const fp)
+ FUNC_ATTR_NONNULL_ALL
+{
+ if (!fp->wr) {
+ return 0;
}
- const int error = os_fsync(fp->fd);
- if (error != UV_EINVAL && error != UV_EROFS) {
- return error;
+ const int flush_error = file_flush(fp);
+ if (flush_error != 0) {
+ return flush_error;
+ }
+ const int fsync_error = os_fsync(fp->fd);
+ if (fsync_error != UV_EINVAL && fsync_error != UV_EROFS) {
+ return fsync_error;
}
return 0;
}