From 6f8b62333fbf2caf3587207ba49d1c5e0d40eeff Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Tue, 7 Nov 2017 13:20:25 +0100 Subject: [PATCH] Use real UUIDs for Utility::NewUniqueID --- CMakeLists.txt | 2 +- lib/base/utility.cpp | 24 +++--------------------- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 52c698bb0..9af23aef4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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") diff --git a/lib/base/utility.cpp b/lib/base/utility.cpp index 836393b03..791c6751c 100644 --- a/lib/base/utility.cpp +++ b/lib/base/utility.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -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(u); } #ifdef _WIN32