Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
c7b0fb51
Commit
c7b0fb51
authored
Jun 03, 2015
by
Piotr Caban
Committed by
Alexandre Julliard
Jun 03, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt: Use fd critical section in dup2.
parent
c0af3fad
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
6 deletions
+29
-6
file.c
dlls/msvcrt/file.c
+29
-6
No files found.
dlls/msvcrt/file.c
View file @
c7b0fb51
...
...
@@ -260,8 +260,15 @@ static inline ioinfo* get_ioinfo_nolock(int fd)
static
inline
ioinfo
*
get_ioinfo
(
int
fd
)
{
ioinfo
*
ret
=
get_ioinfo_nolock
(
fd
);
if
(
ret
->
exflag
&
EF_CRIT_INIT
)
EnterCriticalSection
(
&
ret
->
crit
);
if
(
!
(
ret
->
exflag
&
EF_CRIT_INIT
))
{
LOCK_FILES
();
if
(
!
(
ret
->
exflag
&
EF_CRIT_INIT
))
{
InitializeCriticalSection
(
&
ret
->
crit
);
ret
->
exflag
|=
EF_CRIT_INIT
;
}
UNLOCK_FILES
();
}
EnterCriticalSection
(
&
ret
->
crit
);
return
ret
;
}
...
...
@@ -1016,20 +1023,33 @@ int CDECL MSVCRT__close(int fd)
*/
int
CDECL
MSVCRT__dup2
(
int
od
,
int
nd
)
{
ioinfo
*
info_od
,
*
info_nd
;
int
ret
;
TRACE
(
"(od=%d, nd=%d)
\n
"
,
od
,
nd
);
LOCK_FILES
();
if
(
nd
<
MSVCRT_MAX_FILES
&&
nd
>=
0
&&
msvcrt_is_valid_fd
(
od
))
if
(
od
<
nd
)
{
info_od
=
get_ioinfo
(
od
);
info_nd
=
get_ioinfo
(
nd
);
}
else
{
info_nd
=
get_ioinfo
(
nd
);
info_od
=
get_ioinfo
(
od
);
}
if
(
nd
<
MSVCRT_MAX_FILES
&&
nd
>=
0
&&
(
info_od
->
wxflag
&
WX_OPEN
))
{
HANDLE
handle
;
if
(
DuplicateHandle
(
GetCurrentProcess
(),
get_ioinfo_nolock
(
od
)
->
handle
,
if
(
DuplicateHandle
(
GetCurrentProcess
(),
info_od
->
handle
,
GetCurrentProcess
(),
&
handle
,
0
,
TRUE
,
DUPLICATE_SAME_ACCESS
))
{
int
wxflag
=
get_ioinfo_nolock
(
od
)
->
wxflag
&
~
MSVCRT__O_NOINHERIT
;
int
wxflag
=
info_od
->
wxflag
&
~
MSVCRT__O_NOINHERIT
;
if
(
msvcrt_is_valid_fd
(
nd
)
)
if
(
info_nd
->
wxflag
&
WX_OPEN
)
MSVCRT__close
(
nd
);
ret
=
msvcrt_set_fd
(
handle
,
wxflag
,
nd
);
if
(
ret
==
-
1
)
...
...
@@ -1054,6 +1074,9 @@ int CDECL MSVCRT__dup2(int od, int nd)
*
MSVCRT__errno
()
=
MSVCRT_EBADF
;
ret
=
-
1
;
}
release_ioinfo
(
info_od
);
release_ioinfo
(
info_nd
);
UNLOCK_FILES
();
return
ret
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment