]> granicus.if.org Git - icinga2/commitdiff
Use real UUIDs for Utility::NewUniqueID 5725/head
authorGunnar Beutner <gunnar.beutner@icinga.com>
Tue, 7 Nov 2017 12:20:25 +0000 (13:20 +0100)
committerGunnar Beutner <gunnar.beutner@icinga.com>
Tue, 7 Nov 2017 12:53:04 +0000 (13:53 +0100)
CMakeLists.txt
lib/base/utility.cpp

index 52c698bb0f70d0bf3c959de4e50482ef8c775ea6..9af23aef4870f7058e76fa7d58afd8fa7930170f 100644 (file)
@@ -16,7 +16,7 @@
 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 
 cmake_minimum_required(VERSION 2.6)
-set(BOOST_MIN_VERSION "1.41.0")
+set(BOOST_MIN_VERSION "1.48.0")
 
 project(icinga2)
 list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
index 836393b03224778cc1a4000ad82555964ff4756f..791c6751c0e25e7ebe46a3df58663fc76e933f61 100644 (file)
@@ -32,6 +32,7 @@
 #include <boost/algorithm/string/classification.hpp>
 #include <boost/algorithm/string/trim.hpp>
 #include <boost/algorithm/string/replace.hpp>
+#include <boost/uuid/uuid_io.hpp>
 #include <ios>
 #include <fstream>
 #include <iostream>
@@ -438,27 +439,8 @@ void Utility::Sleep(double timeout)
  */
 String Utility::NewUniqueID(void)
 {
-       static boost::mutex mutex;
-       static int next_id = 0;
-
-       /* I'd much rather use UUIDs but RHEL is way too cool to have
-        * a semi-recent version of boost. Yay. */
-
-       String id;
-
-       char buf[128];
-       if (gethostname(buf, sizeof(buf)) == 0)
-               id = String(buf) + "-";
-
-       id += Convert::ToString((long)Utility::GetTime()) + "-";
-
-       {
-               boost::mutex::scoped_lock lock(mutex);
-               id += Convert::ToString(next_id);
-               next_id++;
-       }
-
-       return id;
+       boost::uuids::uuid u;
+       return boost::lexical_cast<std::string>(u);
 }
 
 #ifdef _WIN32