]> granicus.if.org Git - icinga2/commitdiff
Revert "Fix incorrect detection of the 'Concurrency' variable"
authorGunnar Beutner <gunnar.beutner@netways.de>
Fri, 19 Aug 2016 09:58:40 +0000 (11:58 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Fri, 19 Aug 2016 09:58:52 +0000 (11:58 +0200)
This reverts commit 585f0537d244fb8fb229924f9e7c5c8478bb2a92.

refs #12456

icinga-app/icinga.cpp
lib/base/application.cpp
lib/base/unix.hpp
lib/base/utility.cpp
lib/base/utility.hpp

index bd5042a0b5afaf93e325481b5542041185da67df..f50450525e43415b157f3181d31153487584c120 100644 (file)
@@ -152,7 +152,7 @@ int Main(void)
        Application::DeclareZonesDir(Application::GetSysconfDir() + "/icinga2/zones.d");
        Application::DeclareRunAsUser(ICINGA_USER);
        Application::DeclareRunAsGroup(ICINGA_GROUP);
-       Application::DeclareConcurrency(Utility::PhysicalConcurrency());
+       Application::DeclareConcurrency(boost::thread::hardware_concurrency());
 
        if (!ScriptGlobal::Exists("UseVfork"))
 #ifdef __APPLE__
index 712af5c22f3de1017361d949dac2f3f7a4e5e72f..9746b013034bf5a29d3d86c5b8c32f004fd25ba1 100644 (file)
@@ -1344,7 +1344,7 @@ void Application::DeclareConcurrency(int ncpus)
  */
 int Application::GetConcurrency(void)
 {
-       static Value defaultConcurrency = Utility::PhysicalConcurrency();
+       Value defaultConcurrency = boost::thread::hardware_concurrency();
        return ScriptGlobal::Get("Concurrency", &defaultConcurrency);
 }
 
index ab9881aadbb10aca292ada033d07b2a8f5236723..9fe8b7d2ee6fd3f8d2ed29455a4a10d863be06cb 100644 (file)
@@ -41,7 +41,6 @@
 #include <sys/time.h>
 #include <sys/resource.h>
 #include <strings.h>
-#include <sys/sysctl.h>
 
 typedef int SOCKET;
 #define INVALID_SOCKET (-1)
index 29c98e139e519ecb5c9e665b456b26a9e9bd6f1a..82470822fd6b60e8951963a01372f9ea766a5f24 100644 (file)
@@ -1936,69 +1936,3 @@ String Utility::GetIcingaDataPath(void)
 }
 
 #endif /* _WIN32 */
-
-int Utility::PhysicalConcurrency(void)
-{
-#if BOOST_VERSION >= 106100
-       return boost::thread::physical_concurrency();
-#elif defined(__linux__)
-       std::ifstream fp("/proc/cpuinfo");
-       std::string line;
-       bool htFlag = false;
-
-       while (std::getline(fp, line)) {
-               std::vector<String> tokens;
-               boost::algorithm::split(tokens, line, boost::is_any_of(":"));
-
-               if (tokens.size() != 2)
-                       continue;
-
-               String key = tokens[0].Trim();
-               String value = tokens[1].Trim();
-
-               if (key != "flags")
-                       continue;
-
-               std::vector<String> flags;
-               boost::algorithm::split(flags, value, boost::is_any_of(" "));
-
-               if (std::find(flags.begin(), flags.end(), "ht") != flags.end()) {
-                       htFlag = true;
-                       break;
-               }
-       }
-
-       return boost::thread::hardware_concurrency() / (htFlag ? 2 : 1);
-#elif defined(_WIN32)
-       DWORD size = 0;
-
-       GetLogicalProcessorInformation(NULL, &size);
-
-       if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
-               return boost::thread::hardware_concurrency();
-
-       std::vector<SYSTEM_LOGICAL_PROCESSOR_INFORMATION> info(size / sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION));
-
-       if (GetLogicalProcessorInformation(&info.front(), &size) == FALSE)
-               return boost::thread::hardware_concurrency();
-
-       int ncpus = 0;
-
-       BOOST_FOREACH(const SYSTEM_LOGICAL_PROCESSOR_INFORMATION& slpi, info) {
-               if (slpi.Relationship == RelationProcessorCore)
-                       ncpus++;
-       }
-
-       return ncpus;
-#elif defined(__APPLE__)
-       int ncpus;
-       size_t size = sizeof(ncpus);
-
-       if (sysctlbyname("hw.physicalcpu", &ncpus, &size, NULL, 0) == 0)
-               return ncpus;
-       else
-               return boost::thread::hardware_concurrency();
-#else /* __APPLE__ */
-       return boost::thread::hardware_concurrency();
-#endif /* __APPLE__ */
-}
index 36885292aa8a2532df3ea5d67b7cef12d54bde1a..0e1fcc29ff3233647e8f4cd1de10e9429f4462e1 100644 (file)
@@ -153,8 +153,6 @@ public:
        static void IncrementTime(double);
 #endif /* I2_DEBUG */
 
-       static int PhysicalConcurrency(void);
-
 private:
        Utility(void);
        static void CollectPaths(const String& path, std::vector<String>& paths);