summaryrefslogtreecommitdiff
path: root/qpid/cpp/src/qpid/linearstore/journal/JournalFile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qpid/cpp/src/qpid/linearstore/journal/JournalFile.cpp')
-rw-r--r--qpid/cpp/src/qpid/linearstore/journal/JournalFile.cpp14
1 files changed, 2 insertions, 12 deletions
diff --git a/qpid/cpp/src/qpid/linearstore/journal/JournalFile.cpp b/qpid/cpp/src/qpid/linearstore/journal/JournalFile.cpp
index 129a9145d0..1b2025bd5a 100644
--- a/qpid/cpp/src/qpid/linearstore/journal/JournalFile.cpp
+++ b/qpid/cpp/src/qpid/linearstore/journal/JournalFile.cpp
@@ -279,18 +279,8 @@ const std::string JournalFile::getFileName() const {
//static
uint64_t JournalFile::getRandom64() {
- int randomData = ::open("/dev/urandom", O_RDONLY);
- if (randomData < 0) {
- throw jexception(); // TODO: Complete exception details
- }
- uint64_t randomNumber;
- ::size_t size = sizeof(randomNumber);
- ::ssize_t result = ::read(randomData, (char*)&randomNumber, size);
- if (result < 0 || result != ssize_t(size)) {
- throw jexception(); // TODO: Complete exception details
- }
- ::close(randomData);
- return randomNumber;
+ // TODO: ::rand() is not thread safe, either lock or use rand_r(seed) with a thread-local seed.
+ return ((uint64_t)::rand() << QLS_RAND_SHIFT1) | ((uint64_t)::rand() << QLS_RAND_SHIFT2) | (::rand() & QLS_RAND_MASK);
}
bool JournalFile::isOpen() const {