fix generateUUID

This commit is contained in:
badaix 2016-12-11 13:30:13 +01:00
parent f17797b43d
commit 4206ccb3c3

View file

@ -269,7 +269,12 @@ static long uptime()
/// http://stackoverflow.com/questions/2174768/generating-random-uuids-in-linux
static std::string generateUUID()
{
std::srand(std::time(0));
static bool initialized(false);
if (!initialized)
{
std::srand(std::time(0));
initialized = true;
}
std::stringstream ss;
ss << std::setfill('0') << std::hex
<< std::setw(4) << (std::rand() % 0xffff) << std::setw(4) << (std::rand() % 0xffff)