diff --git a/db/db.cpp b/db/db.cpp index ab72ada24db..0860e23c24e 100644 --- a/db/db.cpp +++ b/db/db.cpp @@ -318,7 +318,7 @@ namespace mongo { repairDatabases(); /* this is for security on certain platforms */ - srand(curTimeMillis() ^ startupSrandTimer.micros()); + srand(curTimeMicros() ^ startupSrandTimer.micros()); listen(listenPort); } @@ -334,7 +334,7 @@ using namespace mongo; int main(int argc, char* argv[], char *envp[] ) { - srand(curTimeMillis()); + srand(curTimeMicros()); boost::filesystem::path::default_name_check( boost::filesystem::no_check ); { diff --git a/db/security.cpp b/db/security.cpp index db54d3ce22e..a333b0ed9dd 100644 --- a/db/security.cpp +++ b/db/security.cpp @@ -14,6 +14,10 @@ namespace mongo { #if defined(__linux__) devrandom = new ifstream("/dev/urandom", ios::binary|ios::in); massert( "can't open dev/urandom", devrandom->is_open() ); +#elif defined(_WIN32) + srand(curTimeMicros()); +#else + srandomdev(); #endif assert( sizeof(nonce) == 8 ); @@ -26,8 +30,10 @@ namespace mongo { #if defined(__linux__) devrandom->read((char*)&n, sizeof(n)); massert("devrandom failed", !devrandom->fail()); -#else +#elif defined(_WIN32) n = ((unsigned long long)rand())<<32 | rand(); +#else + n = random(); #endif return n; }