mirror of
https://github.com/OpenNebula/one.git
synced 2025-02-27 13:57:23 +03:00
Fix random election timeout rounds (srand(0) == srand(1) for glibc)
This commit is contained in:
parent
5f77b49c85
commit
360cef02f0
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user