Unbuffered-IO in Windows is incredibly slow. Instead call fflush() after fprintf().
authorHiroshi Inoue <h-inoue@dream.email.ne.jp>
Fri, 26 Oct 2018 05:15:22 +0000 (14:15 +0900)
committerHiroshi Inoue <h-inoue@dream.email.ne.jp>
Fri, 26 Oct 2018 05:15:22 +0000 (14:15 +0900)
mylog.c

diff --git a/mylog.c b/mylog.c
index a937800b9a3b26f90f07d345cdb42ccd03b26887..9377ad2c0486642c711ec8acfaefa6bd579d9ac5 100644 (file)
--- a/mylog.c
+++ b/mylog.c
@@ -304,7 +304,6 @@ static void MLOG_open()
    }
    if (MLOGFP)
    {
-       setbuf(MLOGFP, NULL);
        if (open_error)
            fputs(errbuf, MLOGFP);
    }
@@ -349,6 +348,7 @@ mylog_misc(unsigned int option, const char *fmt, va_list args)
 #endif /* POSIX_MULTITHREAD_SUPPORT */
        }
        vfprintf(MLOGFP, fmt, args);
+       fflush(MLOGFP);
    }
 
    // va_end(args);
@@ -427,9 +427,7 @@ qlog_misc(unsigned int option, const char *fmt, va_list args)
            generate_homefile(QLOGFILE, filebuf, sizeof(filebuf));
            QLOGFP = fopen(filebuf, PG_BINARY_A);
        }
-       if (QLOGFP)
-           setbuf(QLOGFP, NULL);
-       else
+       if (!QLOGFP)
            qlog_on = 0;
    }
 
@@ -443,6 +441,7 @@ qlog_misc(unsigned int option, const char *fmt, va_list args)
 #endif /* LOGGING_PROCESS_TIME */
        }
        vfprintf(QLOGFP, fmt, args);
+       fflush(QLOGFP);
    }
 
    LEAVE_QLOG_CS;