Merge pull request #5725 from Icinga/feature/proper-uuids

Use real UUIDs for Utility::NewUniqueID
This commit is contained in:
Gunnar Beutner 2017-11-27 10:18:52 +01:00 committed by GitHub
commit 1b4206e5b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 22 deletions

View File

@ -16,7 +16,7 @@
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
cmake_minimum_required(VERSION 2.6) cmake_minimum_required(VERSION 2.6)
set(BOOST_MIN_VERSION "1.41.0") set(BOOST_MIN_VERSION "1.48.0")
project(icinga2) project(icinga2)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

View File

@ -32,6 +32,7 @@
#include <boost/algorithm/string/classification.hpp> #include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/trim.hpp> #include <boost/algorithm/string/trim.hpp>
#include <boost/algorithm/string/replace.hpp> #include <boost/algorithm/string/replace.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <ios> #include <ios>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
@ -438,27 +439,8 @@ void Utility::Sleep(double timeout)
*/ */
String Utility::NewUniqueID(void) String Utility::NewUniqueID(void)
{ {
static boost::mutex mutex; boost::uuids::uuid u;
static int next_id = 0; return boost::lexical_cast<std::string>(u);
/* 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;
} }
#ifdef _WIN32 #ifdef _WIN32