[SIGAR-26] Change Pdh.getFormattedValue() to collect 2 counters if needed

This commit is contained in:
Doug MacEachern 2006-12-04 19:45:00 +00:00
parent d4f10e9cc7
commit 228ee133be
2 changed files with 18 additions and 5 deletions

View File

@ -1,4 +1,8 @@
2006-12-03 Doug MacEachern <dougm@hyperic.net>
2006-12-04 Doug MacEachern <dougm@hyperic.com>
* [SIGAR-26] Change Pdh.getFormattedValue() to collect 2 counters if needed
2006-12-03 Doug MacEachern <dougm@hyperic.com>
* [SIGAR-19] Change cpu time units to milliseconds

View File

@ -173,10 +173,19 @@ JNIEXPORT jdouble SIGAR_JNI(win32_Pdh_pdhGetValue)
}
if (fmt) {
status = PdhGetFormattedCounterValue(h_counter,
PDH_FMT_DOUBLE,
(LPDWORD)NULL,
&fmt_value);
/* may require 2 counters, see msdn docs */
int i=0;
for (i=0; i<2; i++) {
status = PdhGetFormattedCounterValue(h_counter,
PDH_FMT_DOUBLE,
(LPDWORD)NULL,
&fmt_value);
if (status == ERROR_SUCCESS) {
break;
}
PdhCollectQueryData(h_query);
}
}
else {
status = PdhGetRawCounterValue(h_counter, &type, &raw_value);