From 4904ec5d3fccf15d6fcb9396dba4c4b5d076a739 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 4 Jun 2011 14:01:56 +0200 Subject: [PATCH] Fixed: Number of processors under Linux --- code/nel/src/misc/system_info.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/code/nel/src/misc/system_info.cpp b/code/nel/src/misc/system_info.cpp index 97397f001..54273be94 100644 --- a/code/nel/src/misc/system_info.cpp +++ b/code/nel/src/misc/system_info.cpp @@ -66,15 +66,20 @@ namespace NLMISC { vector splitted; explode(string(buffer), string("\n"), splitted, true); + std::string value; + for(uint32 i = 0; i < splitted.size(); i++) { vector sline; explode(splitted[i], string(":"), sline, true); if(sline.size() == 2 && trim(sline[0]) == colname) { - return trim(sline[1]); + value = sline[1]; } } + + if (!value.empty()) + return trim(value); } nlwarning ("SI: Can't find the colname '%s' in /proc/cpuinfo", colname.c_str()); return ""; @@ -549,7 +554,7 @@ string CSystemInfo::getOS() { OSString += " Professional"; } - else + else { if( osvi.wSuiteMask & VER_SUITE_DATACENTER ) OSString += " Datacenter Server"; @@ -805,6 +810,9 @@ string CSystemInfo::getProc () #elif defined NL_OS_UNIX + uint processors = 0; + if (fromString(getCpuInfo("processor"), processors)) ++processors; + ProcString = getCpuInfo("model name"); ProcString += " / ?"; ProcString += " Family " + getCpuInfo("cpu family"); @@ -815,7 +823,7 @@ string CSystemInfo::getProc () ProcString += " / "; ProcString += getCpuInfo("cpu MHz")+"MHz"; ProcString += " / "; - ProcString += "? Processors found"; + ProcString += toString("%u Processors found", processors); #endif