X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Fuuid.cpp;h=4a1038b330caf66e4be141bc251e5dcd14b965b6;hb=88277a52069ed0135254ce29da617ebb6ecddbb8;hp=dd59edc31c79e532f6b14bb8caa84d731fa430ef;hpb=52cb8c0f651ade8d057a264eea1de534ead36517;p=lttng-tools.git diff --git a/src/common/uuid.cpp b/src/common/uuid.cpp index dd59edc31..4a1038b33 100644 --- a/src/common/uuid.cpp +++ b/src/common/uuid.cpp @@ -7,6 +7,10 @@ */ #include +#include +#include +#include + #include #include #include @@ -78,18 +82,15 @@ int lttng_uuid_generate(lttng_uuid& uuid_out) int i, ret = 0; if (!lttng_uuid_is_init) { - /* - * We don't need cryptographic quality randomness to - * generate UUIDs, seed rand with the epoch. - */ - const time_t epoch = time(NULL); - - if (epoch == (time_t) -1) { + try { + srand(lttng::random::produce_best_effort_random_seed()); + } catch (std::exception& e) { + ERR("Failed to initialize random seed during generation of UUID: %s", + e.what()); ret = -1; goto end; } - srand(epoch); lttng_uuid_is_init = true; }