=?UTF-8?Q?Iv=C3=A1n=20Matellanes=20?=: msvcrt: _filbuf should not lock any file.
Alexandre Julliard
julliard at wine.codeweavers.com
Fri Oct 31 02:53:36 CDT 2014
Module: wine
Branch: master
Commit: f896cd3dc9fc16586dd7ada2e95b66c677aad1ac
URL: http://source.winehq.org/git/wine.git/?a=commit;h=f896cd3dc9fc16586dd7ada2e95b66c677aad1ac
Author: Iván Matellanes <matellanesivan at gmail.com>
Date: Tue Oct 28 14:43:35 2014 +0100
msvcrt: _filbuf should not lock any file.
---
dlls/msvcr90/tests/msvcr90.c | 7 +++++++
dlls/msvcrt/file.c | 13 ++-----------
2 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/dlls/msvcr90/tests/msvcr90.c b/dlls/msvcr90/tests/msvcr90.c
index 9bb29da..184ce76 100644
--- a/dlls/msvcr90/tests/msvcr90.c
+++ b/dlls/msvcr90/tests/msvcr90.c
@@ -118,6 +118,7 @@ static int (__cdecl *p_fileno)(FILE*);
static int (__cdecl *p_feof)(FILE*);
static int (__cdecl *p_ferror)(FILE*);
static int (__cdecl *p_flsbuf)(int, FILE*);
+static int (__cdecl *p_filbuf)(FILE*);
static unsigned long (__cdecl *p_byteswap_ulong)(unsigned long);
static void** (__cdecl *p__pxcptinfoptrs)(void);
static void* (__cdecl *p__AdjustPointer)(void*, const void*);
@@ -377,6 +378,7 @@ static BOOL init(void)
SET(p_feof, "feof");
SET(p_ferror, "ferror");
SET(p_flsbuf, "_flsbuf");
+ SET(p_filbuf, "_filbuf");
SET(p_byteswap_ulong, "_byteswap_ulong");
SET(p__pxcptinfoptrs, "__pxcptinfoptrs");
SET(p__AdjustPointer, "__AdjustPointer");
@@ -1285,6 +1287,11 @@ static void test_nonblocking_file_access(void)
ret = p_flsbuf('a', filew);
ok(ret=='a', "_flsbuf(filew) returned %d\n", ret);
+ ret = p_filbuf(filer);
+ ok(ret==-1, "_filbuf(filer) returned %d\n", ret);
+ ret = p_filbuf(filew);
+ ok(ret==-1, "_filbuf(filew) returned %d\n", ret);
+
ret = p_fflush_nolock(filer);
ok(ret==0, "_fflush_nolock(filer) returned %d\n", ret);
ret = p_fflush_nolock(filew);
diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c
index 2e07342..d191953 100644
--- a/dlls/msvcrt/file.c
+++ b/dlls/msvcrt/file.c
@@ -3460,12 +3460,9 @@ int CDECL MSVCRT_ferror(MSVCRT_FILE* file)
int CDECL MSVCRT__filbuf(MSVCRT_FILE* file)
{
unsigned char c;
- MSVCRT__lock_file(file);
- if(file->_flag & MSVCRT__IOSTRG) {
- MSVCRT__unlock_file(file);
+ if(file->_flag & MSVCRT__IOSTRG)
return MSVCRT_EOF;
- }
/* Allocate buffer if needed */
if(!(file->_flag & (MSVCRT__IONBF | MSVCRT__IOMYBUF | MSVCRT__USERBUF)))
@@ -3474,35 +3471,29 @@ int CDECL MSVCRT__filbuf(MSVCRT_FILE* file)
if(!(file->_flag & MSVCRT__IOREAD)) {
if(file->_flag & MSVCRT__IORW)
file->_flag |= MSVCRT__IOREAD;
- else {
- MSVCRT__unlock_file(file);
+ else
return MSVCRT_EOF;
- }
}
if(!(file->_flag & (MSVCRT__IOMYBUF | MSVCRT__USERBUF))) {
int r;
if ((r = read_i(file->_file,&c,1)) != 1) {
file->_flag |= (r == 0) ? MSVCRT__IOEOF : MSVCRT__IOERR;
- MSVCRT__unlock_file(file);
return MSVCRT_EOF;
}
- MSVCRT__unlock_file(file);
return c;
} else {
file->_cnt = read_i(file->_file, file->_base, file->_bufsiz);
if(file->_cnt<=0) {
file->_flag |= (file->_cnt == 0) ? MSVCRT__IOEOF : MSVCRT__IOERR;
file->_cnt = 0;
- MSVCRT__unlock_file(file);
return MSVCRT_EOF;
}
file->_cnt--;
file->_ptr = file->_base+1;
c = *(unsigned char *)file->_base;
- MSVCRT__unlock_file(file);
return c;
}
}
More information about the wine-cvs
mailing list