Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
55d274d1
Commit
55d274d1
authored
Oct 30, 2007
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pdh: Fix a couple of race conditions in the thread handling.
parent
0f16c149
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
16 deletions
+28
-16
pdh_main.c
dlls/pdh/pdh_main.c
+28
-16
No files found.
dlls/pdh/pdh_main.c
View file @
55d274d1
...
...
@@ -380,17 +380,6 @@ PDH_STATUS WINAPI PdhCalculateCounterFromRawValue( PDH_HCOUNTER handle, DWORD fo
return
ret
;
}
/* caller must hold query lock */
static
void
shutdown_query_thread
(
struct
query
*
query
)
{
SetEvent
(
query
->
stop
);
WaitForSingleObject
(
query
->
thread
,
INFINITE
);
CloseHandle
(
query
->
stop
);
CloseHandle
(
query
->
thread
);
query
->
thread
=
NULL
;
}
/***********************************************************************
* PdhCloseQuery (PDH.@)
...
...
@@ -409,7 +398,20 @@ PDH_STATUS WINAPI PdhCloseQuery( PDH_HQUERY handle )
return
PDH_INVALID_HANDLE
;
}
if
(
query
->
thread
)
shutdown_query_thread
(
query
);
if
(
query
->
thread
)
{
HANDLE
thread
=
query
->
thread
;
SetEvent
(
query
->
stop
);
LeaveCriticalSection
(
&
pdh_handle_cs
);
WaitForSingleObject
(
thread
,
INFINITE
);
EnterCriticalSection
(
&
pdh_handle_cs
);
if
(
query
->
magic
!=
PDH_MAGIC_QUERY
)
return
ERROR_SUCCESS
;
CloseHandle
(
query
->
stop
);
CloseHandle
(
query
->
thread
);
query
->
thread
=
NULL
;
}
LIST_FOR_EACH_SAFE
(
item
,
next
,
&
query
->
counters
)
{
...
...
@@ -476,7 +478,6 @@ static DWORD CALLBACK collect_query_thread( void *arg )
DWORD
interval
=
query
->
interval
;
HANDLE
stop
=
query
->
stop
;
SetEvent
(
stop
);
for
(;;)
{
if
(
WaitForSingleObject
(
stop
,
interval
)
!=
WAIT_TIMEOUT
)
ExitThread
(
0
);
...
...
@@ -520,8 +521,20 @@ PDH_STATUS WINAPI PdhCollectQueryDataEx( PDH_HQUERY handle, DWORD interval, HAND
LeaveCriticalSection
(
&
pdh_handle_cs
);
return
PDH_NO_DATA
;
}
if
(
query
->
thread
)
shutdown_query_thread
(
query
);
if
(
!
(
query
->
stop
=
CreateEventW
(
NULL
,
FALSE
,
FALSE
,
NULL
)))
if
(
query
->
thread
)
{
HANDLE
thread
=
query
->
thread
;
SetEvent
(
query
->
stop
);
LeaveCriticalSection
(
&
pdh_handle_cs
);
WaitForSingleObject
(
thread
,
INFINITE
);
EnterCriticalSection
(
&
pdh_handle_cs
);
if
(
query
->
magic
!=
PDH_MAGIC_QUERY
)
return
PDH_INVALID_HANDLE
;
CloseHandle
(
query
->
thread
);
query
->
thread
=
NULL
;
}
else
if
(
!
(
query
->
stop
=
CreateEventW
(
NULL
,
FALSE
,
FALSE
,
NULL
)))
{
ret
=
GetLastError
();
LeaveCriticalSection
(
&
pdh_handle_cs
);
...
...
@@ -537,7 +550,6 @@ PDH_STATUS WINAPI PdhCollectQueryDataEx( PDH_HQUERY handle, DWORD interval, HAND
LeaveCriticalSection
(
&
pdh_handle_cs
);
return
ret
;
}
WaitForSingleObject
(
query
->
stop
,
INFINITE
);
LeaveCriticalSection
(
&
pdh_handle_cs
);
return
ERROR_SUCCESS
;
...
...
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