From 9ba78fcfa3dec88928df33be26821e3fd5a10727 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Fri, 20 Mar 2015 14:57:59 +0100 Subject: Use FlushFileBuffers in Windows --- include/astra/clog.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/include/astra/clog.h b/include/astra/clog.h index c0cbae4..6ffb660 100644 --- a/include/astra/clog.h +++ b/include/astra/clog.h @@ -74,6 +74,8 @@ #ifndef _MSC_VER #include #else +#define WIN32_LEAN_AND_MEAN +#include #include #define open _open #define close _close @@ -634,8 +636,13 @@ _clog_log(const char *sfile, int sline, enum clog_level level, free(dynbuf); } #ifndef _MSC_VER - // FIXME fsync(logger->fd); +#else + HANDLE h = (HANDLE) _get_osfhandle(logger->fd); + if (h != INVALID_HANDLE_VALUE) { + // This call will fail on a console fd, but that's ok. + FlushFileBuffers(h); + } #endif } } -- cgit v1.2.3