From d18f0766f72b669eb630371cf4fe4de267dcbc99 Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Fri, 20 May 2011 13:21:29 +0200 Subject: [PATCH] msvcrt: Make fflush function thread safe. --- dlls/msvcrt/file.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c index b9c7e907103..e6ad5d09595 100644 --- a/dlls/msvcrt/file.c +++ b/dlls/msvcrt/file.c @@ -774,13 +774,18 @@ int CDECL _flushall(void) */ int CDECL MSVCRT_fflush(MSVCRT_FILE* file) { - if(!file) { - _flushall(); - } else if(file->_flag & MSVCRT__IOWRT) { - int res=msvcrt_flush_buffer(file); - return res; - } - return 0; + if(!file) { + _flushall(); + } else if(file->_flag & MSVCRT__IOWRT) { + int res; + + MSVCRT__lock_file(file); + res = msvcrt_flush_buffer(file); + MSVCRT__unlock_file(file); + + return res; + } + return 0; } /*********************************************************************