msvcrt: _filbuf should not lock any file.
This commit is contained in:
parent
2c5f05b860
commit
f896cd3dc9
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue