Module: wine Branch: master Commit: 9a4cfbc3edce79a1cca12b7dbed39fa14a9d65c2 URL: http://source.winehq.org/git/wine.git/?a=commit;h=9a4cfbc3edce79a1cca12b7dbe...
Author: Piotr Caban piotr@codeweavers.com Date: Fri Dec 5 14:42:44 2014 +0100
msvcrt: Use fd critical section in _eof.
---
dlls/msvcrt/file.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c index 5176f58..317e19e 100644 --- a/dlls/msvcrt/file.c +++ b/dlls/msvcrt/file.c @@ -1081,29 +1081,38 @@ int CDECL MSVCRT__dup(int od) */ int CDECL MSVCRT__eof(int fd) { + ioinfo *info = get_ioinfo(fd); DWORD curpos,endpos; LONG hcurpos,hendpos; - HANDLE hand = msvcrt_fdtoh(fd);
- TRACE(":fd (%d) handle (%p)\n",fd,hand); + TRACE(":fd (%d) handle (%p)\n", fd, info->handle);
- if (hand == INVALID_HANDLE_VALUE) + if (info->handle == INVALID_HANDLE_VALUE) + { + release_ioinfo(info); return -1; + }
- if (get_ioinfo_nolock(fd)->wxflag & WX_ATEOF) return TRUE; + if (info->wxflag & WX_ATEOF) + { + release_ioinfo(info); + return TRUE; + }
/* Otherwise we do it the hard way */ hcurpos = hendpos = 0; - curpos = SetFilePointer(hand, 0, &hcurpos, FILE_CURRENT); - endpos = SetFilePointer(hand, 0, &hendpos, FILE_END); + curpos = SetFilePointer(info->handle, 0, &hcurpos, FILE_CURRENT); + endpos = SetFilePointer(info->handle, 0, &hendpos, FILE_END);
if (curpos == endpos && hcurpos == hendpos) { /* FIXME: shouldn't WX_ATEOF be set here? */ + release_ioinfo(info); return TRUE; }
- SetFilePointer(hand, curpos, &hcurpos, FILE_BEGIN); + SetFilePointer(info->handle, curpos, &hcurpos, FILE_BEGIN); + release_ioinfo(info); return FALSE; }