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_feof)(FILE*);
|
||||||
static int (__cdecl *p_ferror)(FILE*);
|
static int (__cdecl *p_ferror)(FILE*);
|
||||||
static int (__cdecl *p_flsbuf)(int, FILE*);
|
static int (__cdecl *p_flsbuf)(int, FILE*);
|
||||||
|
static int (__cdecl *p_filbuf)(FILE*);
|
||||||
static unsigned long (__cdecl *p_byteswap_ulong)(unsigned long);
|
static unsigned long (__cdecl *p_byteswap_ulong)(unsigned long);
|
||||||
static void** (__cdecl *p__pxcptinfoptrs)(void);
|
static void** (__cdecl *p__pxcptinfoptrs)(void);
|
||||||
static void* (__cdecl *p__AdjustPointer)(void*, const void*);
|
static void* (__cdecl *p__AdjustPointer)(void*, const void*);
|
||||||
|
@ -377,6 +378,7 @@ static BOOL init(void)
|
||||||
SET(p_feof, "feof");
|
SET(p_feof, "feof");
|
||||||
SET(p_ferror, "ferror");
|
SET(p_ferror, "ferror");
|
||||||
SET(p_flsbuf, "_flsbuf");
|
SET(p_flsbuf, "_flsbuf");
|
||||||
|
SET(p_filbuf, "_filbuf");
|
||||||
SET(p_byteswap_ulong, "_byteswap_ulong");
|
SET(p_byteswap_ulong, "_byteswap_ulong");
|
||||||
SET(p__pxcptinfoptrs, "__pxcptinfoptrs");
|
SET(p__pxcptinfoptrs, "__pxcptinfoptrs");
|
||||||
SET(p__AdjustPointer, "__AdjustPointer");
|
SET(p__AdjustPointer, "__AdjustPointer");
|
||||||
|
@ -1285,6 +1287,11 @@ static void test_nonblocking_file_access(void)
|
||||||
ret = p_flsbuf('a', filew);
|
ret = p_flsbuf('a', filew);
|
||||||
ok(ret=='a', "_flsbuf(filew) returned %d\n", ret);
|
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);
|
ret = p_fflush_nolock(filer);
|
||||||
ok(ret==0, "_fflush_nolock(filer) returned %d\n", ret);
|
ok(ret==0, "_fflush_nolock(filer) returned %d\n", ret);
|
||||||
ret = p_fflush_nolock(filew);
|
ret = p_fflush_nolock(filew);
|
||||||
|
|
|
@ -3460,12 +3460,9 @@ int CDECL MSVCRT_ferror(MSVCRT_FILE* file)
|
||||||
int CDECL MSVCRT__filbuf(MSVCRT_FILE* file)
|
int CDECL MSVCRT__filbuf(MSVCRT_FILE* file)
|
||||||
{
|
{
|
||||||
unsigned char c;
|
unsigned char c;
|
||||||
MSVCRT__lock_file(file);
|
|
||||||
|
|
||||||
if(file->_flag & MSVCRT__IOSTRG) {
|
if(file->_flag & MSVCRT__IOSTRG)
|
||||||
MSVCRT__unlock_file(file);
|
|
||||||
return MSVCRT_EOF;
|
return MSVCRT_EOF;
|
||||||
}
|
|
||||||
|
|
||||||
/* Allocate buffer if needed */
|
/* Allocate buffer if needed */
|
||||||
if(!(file->_flag & (MSVCRT__IONBF | MSVCRT__IOMYBUF | MSVCRT__USERBUF)))
|
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__IOREAD)) {
|
||||||
if(file->_flag & MSVCRT__IORW)
|
if(file->_flag & MSVCRT__IORW)
|
||||||
file->_flag |= MSVCRT__IOREAD;
|
file->_flag |= MSVCRT__IOREAD;
|
||||||
else {
|
else
|
||||||
MSVCRT__unlock_file(file);
|
|
||||||
return MSVCRT_EOF;
|
return MSVCRT_EOF;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!(file->_flag & (MSVCRT__IOMYBUF | MSVCRT__USERBUF))) {
|
if(!(file->_flag & (MSVCRT__IOMYBUF | MSVCRT__USERBUF))) {
|
||||||
int r;
|
int r;
|
||||||
if ((r = read_i(file->_file,&c,1)) != 1) {
|
if ((r = read_i(file->_file,&c,1)) != 1) {
|
||||||
file->_flag |= (r == 0) ? MSVCRT__IOEOF : MSVCRT__IOERR;
|
file->_flag |= (r == 0) ? MSVCRT__IOEOF : MSVCRT__IOERR;
|
||||||
MSVCRT__unlock_file(file);
|
|
||||||
return MSVCRT_EOF;
|
return MSVCRT_EOF;
|
||||||
}
|
}
|
||||||
|
|
||||||
MSVCRT__unlock_file(file);
|
|
||||||
return c;
|
return c;
|
||||||
} else {
|
} else {
|
||||||
file->_cnt = read_i(file->_file, file->_base, file->_bufsiz);
|
file->_cnt = read_i(file->_file, file->_base, file->_bufsiz);
|
||||||
if(file->_cnt<=0) {
|
if(file->_cnt<=0) {
|
||||||
file->_flag |= (file->_cnt == 0) ? MSVCRT__IOEOF : MSVCRT__IOERR;
|
file->_flag |= (file->_cnt == 0) ? MSVCRT__IOEOF : MSVCRT__IOERR;
|
||||||
file->_cnt = 0;
|
file->_cnt = 0;
|
||||||
MSVCRT__unlock_file(file);
|
|
||||||
return MSVCRT_EOF;
|
return MSVCRT_EOF;
|
||||||
}
|
}
|
||||||
|
|
||||||
file->_cnt--;
|
file->_cnt--;
|
||||||
file->_ptr = file->_base+1;
|
file->_ptr = file->_base+1;
|
||||||
c = *(unsigned char *)file->_base;
|
c = *(unsigned char *)file->_base;
|
||||||
MSVCRT__unlock_file(file);
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue