Skip to content

Commit

Permalink
add fsync to fflushordie
Browse files Browse the repository at this point in the history
  • Loading branch information
Marko Radmilac committed Jan 28, 2016
1 parent cd1bb59 commit 4c7919a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Source/Common/fileutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,10 +413,23 @@ void fprintfOrDie(FILE* f, const char* fmt, ...)
void fflushOrDie(FILE* f)
{
int rc = fflush(f);

if (rc != 0)
{
RuntimeError("error flushing to file: %s", strerror(errno));
}

#ifndef _WIN32
int fd = fileno(f);

if (fd == -1)
{
RuntimeError("unable to convert file handle to file descriptor: %s", strerror(errno));
}

// Ensure that all data is synced before returning from this function
fsync(fd);
#endif
}

// ----------------------------------------------------------------------------
Expand Down

0 comments on commit 4c7919a

Please sign in to comment.