From efbd406f1b8f148569a40a090c38929a7661d2aa Mon Sep 17 00:00:00 2001 From: Simon Cornish Date: Mon, 2 Sep 2013 23:31:52 -0700 Subject: Fix broken cpu_sup:nprocs and others on Solaris 64-bit The correct kstat datatype for nproc & avenrun_* is ui32, not ulong. Under 64-bit OTP builds garbage was returned because the wrong datatype was used. This patch correcs the datatype. It also adds an additional check in the test case for a slightly less insane return value. --- lib/os_mon/c_src/cpu_sup.c | 4 ++-- lib/os_mon/test/cpu_sup_SUITE.erl | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/os_mon/c_src/cpu_sup.c b/lib/os_mon/c_src/cpu_sup.c index 22946eca0e..e9fd75a32c 100644 --- a/lib/os_mon/c_src/cpu_sup.c +++ b/lib/os_mon/c_src/cpu_sup.c @@ -293,10 +293,10 @@ static unsigned int misc_measure(char* name) { if(!entry) return -1; - if(entry->data_type != KSTAT_DATA_ULONG) + if(entry->data_type != KSTAT_DATA_UINT32) return -1; - return entry->value.ul; + return entry->value.ui32; } diff --git a/lib/os_mon/test/cpu_sup_SUITE.erl b/lib/os_mon/test/cpu_sup_SUITE.erl index d04adbb6d3..e0382cb0c7 100644 --- a/lib/os_mon/test/cpu_sup_SUITE.erl +++ b/lib/os_mon/test/cpu_sup_SUITE.erl @@ -88,6 +88,7 @@ load_api(Config) when is_list(Config) -> ?line N = cpu_sup:nprocs(), ?line true = is_integer(N), ?line true = N>0, + ?line true = N<1000000, %% avg1() ?line Load1 = cpu_sup:avg1(), -- cgit v1.2.3