Use real UUIDs for Utility::NewUniqueID

This commit is contained in:
Gunnar Beutner 2017-11-07 13:20:25 +01:00
parent 36fddaf09b
commit 6f8b62333f
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.
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")

View 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