diff --git a/ChangeLog b/ChangeLog index a342a142..64d3570f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,8 @@ -2006-12-03 Doug MacEachern +2006-12-04 Doug MacEachern + + * [SIGAR-26] Change Pdh.getFormattedValue() to collect 2 counters if needed + +2006-12-03 Doug MacEachern * [SIGAR-19] Change cpu time units to milliseconds diff --git a/bindings/java/src/jni/win32/pdh.c b/bindings/java/src/jni/win32/pdh.c index e707da1e..c9620930 100644 --- a/bindings/java/src/jni/win32/pdh.c +++ b/bindings/java/src/jni/win32/pdh.c @@ -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);