mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-15 09:13:15 +09:00
Fix random election timeout rounds (srand(0) == srand(1) for glibc)
This commit is contained in:
1 parent
d50141d5bc
commit
27403b3c97
1 file changed
+7
-2
@@ -1040,11 +1040,16 @@ void RaftManager::request_vote()
|
||||
|
||||
logdb->update_raft_state(raft_state_xml);
|
||||
|
||||
srand(_server_id);
|
||||
srand(_server_id+1);
|
||||
|
||||
ms = rand() % 500 + election_timeout.tv_sec * 1000
|
||||
ms = rand() % 1000 + election_timeout.tv_sec * 1000
|
||||
+ election_timeout.tv_nsec / 1000000;
|
||||
|
||||
oss.str("");
|
||||
|
||||
oss << "No leader found, starting new election in " << ms << "ms";
|
||||
NebulaLog::log("RCM", Log::INFO, oss);
|
||||
|
||||
set_timeout(ms, etimeout);
|
||||
|
||||
nanosleep(&etimeout, 0);
|
||||
|
||||
Reference in new issue
Block a user