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
0389ec60
Commit
0389ec60
authored
Sep 29, 2007
by
Hans Leidekker
Committed by
Alexandre Julliard
Oct 01, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pdh: Implement and test PdhCollectQueryDataEx.
parent
2f80bc0e
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
145 additions
and
1 deletion
+145
-1
pdh.spec
dlls/pdh/pdh.spec
+1
-1
pdh_main.c
dlls/pdh/pdh_main.c
+91
-0
pdh.c
dlls/pdh/tests/pdh.c
+52
-0
pdh.h
include/pdh.h
+1
-0
No files found.
dlls/pdh/pdh.spec
View file @
0389ec60
...
...
@@ -16,7 +16,7 @@
@ stdcall PdhCloseQuery(ptr)
@ stdcall PdhCollectQueryData(ptr)
@ stdcall PdhCollectQueryDataWithTime(ptr ptr)
@ st
ub PdhCollectQueryDataEx
@ st
dcall PdhCollectQueryDataEx(ptr long ptr)
@ stub PdhComputeCounterStatistics
@ stub PdhConnectMachineA
@ stub PdhConnectMachineW
...
...
dlls/pdh/pdh_main.c
View file @
0389ec60
...
...
@@ -151,6 +151,10 @@ struct query
{
DWORD
magic
;
/* signature */
DWORD_PTR
user
;
/* user data */
HANDLE
thread
;
/* collect thread */
DWORD
interval
;
/* collect interval */
HANDLE
wait
;
/* wait event */
HANDLE
stop
;
/* stop event */
struct
list
counters
;
/* counter list */
};
...
...
@@ -315,6 +319,18 @@ PDH_STATUS WINAPI PdhAddEnglishCounterW( PDH_HQUERY query, LPCWSTR path,
return
PdhAddCounterW
(
query
,
path
,
userdata
,
counter
);
}
/* 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.@)
*/
...
...
@@ -332,6 +348,8 @@ PDH_STATUS WINAPI PdhCloseQuery( PDH_HQUERY handle )
return
PDH_INVALID_HANDLE
;
}
if
(
query
->
thread
)
shutdown_query_thread
(
query
);
LIST_FOR_EACH_SAFE
(
item
,
next
,
&
query
->
counters
)
{
struct
counter
*
counter
=
LIST_ENTRY
(
item
,
struct
counter
,
entry
);
...
...
@@ -391,6 +409,79 @@ PDH_STATUS WINAPI PdhCollectQueryData( PDH_HQUERY handle )
return
ERROR_SUCCESS
;
}
static
DWORD
CALLBACK
collect_query_thread
(
void
*
arg
)
{
struct
query
*
query
=
arg
;
DWORD
interval
=
query
->
interval
;
HANDLE
stop
=
query
->
stop
;
SetEvent
(
stop
);
for
(;;)
{
if
(
WaitForSingleObject
(
stop
,
interval
)
!=
WAIT_TIMEOUT
)
ExitThread
(
0
);
EnterCriticalSection
(
&
pdh_handle_cs
);
if
(
!
query
||
query
->
magic
!=
PDH_MAGIC_QUERY
)
{
LeaveCriticalSection
(
&
pdh_handle_cs
);
ExitThread
(
PDH_INVALID_HANDLE
);
}
collect_query_data
(
query
);
if
(
!
SetEvent
(
query
->
wait
))
{
LeaveCriticalSection
(
&
pdh_handle_cs
);
ExitThread
(
0
);
}
LeaveCriticalSection
(
&
pdh_handle_cs
);
}
}
/***********************************************************************
* PdhCollectQueryDataEx (PDH.@)
*/
PDH_STATUS
WINAPI
PdhCollectQueryDataEx
(
PDH_HQUERY
handle
,
DWORD
interval
,
HANDLE
event
)
{
PDH_STATUS
ret
;
struct
query
*
query
=
handle
;
TRACE
(
"%p %d %p
\n
"
,
handle
,
interval
,
event
);
EnterCriticalSection
(
&
pdh_handle_cs
);
if
(
!
query
||
query
->
magic
!=
PDH_MAGIC_QUERY
)
{
LeaveCriticalSection
(
&
pdh_handle_cs
);
return
PDH_INVALID_HANDLE
;
}
if
(
list_empty
(
&
query
->
counters
))
{
LeaveCriticalSection
(
&
pdh_handle_cs
);
return
PDH_NO_DATA
;
}
if
(
query
->
thread
)
shutdown_query_thread
(
query
);
if
(
!
(
query
->
stop
=
CreateEventW
(
NULL
,
FALSE
,
FALSE
,
NULL
)))
{
ret
=
GetLastError
();
LeaveCriticalSection
(
&
pdh_handle_cs
);
return
ret
;
}
query
->
wait
=
event
;
query
->
interval
=
interval
*
1000
;
if
(
!
(
query
->
thread
=
CreateThread
(
NULL
,
0
,
collect_query_thread
,
query
,
0
,
NULL
)))
{
ret
=
GetLastError
();
CloseHandle
(
query
->
stop
);
LeaveCriticalSection
(
&
pdh_handle_cs
);
return
ret
;
}
WaitForSingleObject
(
query
->
stop
,
INFINITE
);
LeaveCriticalSection
(
&
pdh_handle_cs
);
return
ERROR_SUCCESS
;
}
/***********************************************************************
* PdhCollectQueryDataWithTime (PDH.@)
*/
...
...
dlls/pdh/tests/pdh.c
View file @
0389ec60
...
...
@@ -797,6 +797,56 @@ static void test_PdhValidatePathExW( void )
ok
(
ret
==
ERROR_SUCCESS
,
"PdhValidatePathExW failed 0x%08x
\n
"
,
ret
);
}
static
void
test_PdhCollectQueryDataEx
(
void
)
{
PDH_STATUS
status
;
PDH_HQUERY
query
;
PDH_HCOUNTER
counter
;
HANDLE
event
;
BOOL
ret
;
UINT
i
;
status
=
PdhOpenQueryA
(
NULL
,
0
,
&
query
);
ok
(
status
==
ERROR_SUCCESS
,
"PdhOpenQuery failed 0x%08x
\n
"
,
status
);
event
=
CreateEventA
(
NULL
,
FALSE
,
FALSE
,
"winetest"
);
ok
(
event
!=
NULL
,
"CreateEvent failed
\n
"
);
status
=
PdhAddCounterA
(
query
,
"
\\
System
\\
System Up Time"
,
0
,
&
counter
);
ok
(
status
==
ERROR_SUCCESS
,
"PdhAddCounterA failed 0x%08x
\n
"
,
status
);
status
=
PdhCollectQueryDataEx
(
NULL
,
1
,
event
);
ok
(
status
==
PDH_INVALID_HANDLE
,
"PdhCollectQueryDataEx failed 0x%08x
\n
"
,
status
);
status
=
PdhCollectQueryDataEx
(
query
,
1
,
NULL
);
ok
(
status
==
ERROR_SUCCESS
,
"PdhCollectQueryDataEx failed 0x%08x
\n
"
,
status
);
status
=
PdhCollectQueryDataEx
(
query
,
1
,
event
);
ok
(
status
==
ERROR_SUCCESS
,
"PdhCollectQueryDataEx failed 0x%08x
\n
"
,
status
);
status
=
PdhCollectQueryData
(
query
);
ok
(
status
==
ERROR_SUCCESS
,
"PdhCollectQueryData failed 0x%08x
\n
"
,
status
);
for
(
i
=
0
;
i
<
3
;
i
++
)
{
if
(
WaitForSingleObject
(
event
,
INFINITE
)
==
WAIT_OBJECT_0
)
{
PDH_FMT_COUNTERVALUE
value
;
status
=
PdhGetFormattedCounterValue
(
counter
,
PDH_FMT_LARGE
,
NULL
,
&
value
);
ok
(
status
==
ERROR_SUCCESS
,
"PdhGetFormattedCounterValue failed 0x%08x
\n
"
,
status
);
trace
(
"uptime %x%08x
\n
"
,
(
DWORD
)(
value
.
largeValue
>>
32
),
(
DWORD
)
value
.
largeValue
);
}
}
ret
=
CloseHandle
(
event
);
ok
(
ret
,
"CloseHandle failed
\n
"
);
status
=
PdhCloseQuery
(
query
);
ok
(
status
==
ERROR_SUCCESS
,
"PdhCloseQuery failed 0x%08x
\n
"
,
status
);
}
START_TEST
(
pdh
)
{
init_function_ptrs
();
...
...
@@ -830,4 +880,6 @@ START_TEST(pdh)
if
(
pPdhValidatePathExA
)
test_PdhValidatePathExA
();
if
(
pPdhValidatePathExW
)
test_PdhValidatePathExW
();
test_PdhCollectQueryDataEx
();
}
include/pdh.h
View file @
0389ec60
...
...
@@ -173,6 +173,7 @@ PDH_STATUS WINAPI PdhAddEnglishCounterW(PDH_HQUERY, LPCWSTR, DWORD_PTR, PDH_HCOU
#define PdhAddEnglishCounter WINELIB_NAME_AW(PdhAddEnglishCounter)
PDH_STATUS
WINAPI
PdhCloseQuery
(
PDH_HQUERY
);
PDH_STATUS
WINAPI
PdhCollectQueryData
(
PDH_HQUERY
);
PDH_STATUS
WINAPI
PdhCollectQueryDataEx
(
PDH_HQUERY
,
DWORD
,
HANDLE
);
PDH_STATUS
WINAPI
PdhCollectQueryDataWithTime
(
PDH_HQUERY
,
LONGLONG
*
);
PDH_STATUS
WINAPI
PdhGetCounterInfoA
(
PDH_HCOUNTER
,
BOOLEAN
,
LPDWORD
,
PPDH_COUNTER_INFO_A
);
PDH_STATUS
WINAPI
PdhGetCounterInfoW
(
PDH_HCOUNTER
,
BOOLEAN
,
LPDWORD
,
PPDH_COUNTER_INFO_W
);
...
...
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