Commit 926dfe59 authored by Philip Withnall's avatar Philip Withnall

gstdio: Handle EINTR in g_fsync()

Signed-off-by: Philip Withnall's avatarPhilip Withnall <withnall@endlessm.com>
parent 84dd8924
......@@ -1660,10 +1660,13 @@ g_freopen (const gchar *filename,
* g_fsync:
* @fd: a file descriptor
*
* A wrapper for the POSIX fsync() function (_commit() on Windows).
* The fsync() function is used to synchronize a file's in-core
* A wrapper for the POSIX `fsync()` function. On Windows, `_commit()` will be
* used.
* The `fsync()` function is used to synchronize a file's in-core
* state with that of the disk.
*
* This wrapper will handle retrying on `EINTR`.
*
* See the C library manual for more details about fsync().
*
* Returns: 0 on success, or -1 if an error occurred.
......@@ -1676,8 +1679,14 @@ g_fsync (gint fd)
{
#ifdef G_OS_WIN32
return _commit (fd);
#elif defined(HAVE_FSYNC)
int retval;
do
retval = fsync (fd);
while (G_UNLIKELY (retval < 0 && errno == EINTR));
return retval;
#else
return fsync (fd);
return 0;
#endif
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment