From 193405f1f065a4b1cb6c0a136a9e5965f13993d7 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sun, 28 Jul 2013 12:21:21 +0200 Subject: [PATCH] log.c: Prevent intermingled output from multiple log_message(). --- src/log.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/log.c b/src/log.c index 05bd3dc..05acddf 100644 --- a/src/log.c +++ b/src/log.c @@ -45,6 +45,9 @@ void log_message(int level, const char *file, int line, const char *format, ...) (void)line; #endif + /* Prevent another thread from interrupting the two printfs(). */ + flockfile(stdout); + fprintf(stdout, #ifdef DEBUG "%-12s:%-3d " @@ -58,4 +61,6 @@ void log_message(int level, const char *file, int line, const char *format, ...) vfprintf(stdout, format, ap); va_end(ap); fprintf(stdout, "\n"); + + funlockfile(stdout); } -- 2.44.1