mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-10 01:17:40 +03:00
B #3021: Better randomize when restarting an election process
This commit is contained in:
parent
9e18d65ca6
commit
bc14442af0
@ -915,6 +915,8 @@ void RaftManager::request_vote()
|
||||
|
||||
unsigned int _num_servers = get_zone_servers(_servers);
|
||||
|
||||
srand(time(0) + _server_id + 1);
|
||||
|
||||
do
|
||||
{
|
||||
/* ------------------------------------------------------------------ */
|
||||
@ -1032,10 +1034,9 @@ void RaftManager::request_vote()
|
||||
|
||||
logdb->update_raft_state(raft_state_name, raft_state_xml);
|
||||
|
||||
srand(_server_id+1);
|
||||
|
||||
ms = rand() % 1000 + election_timeout.tv_sec * 1000
|
||||
+ election_timeout.tv_nsec / 1000000;
|
||||
ms = ( (float) rand() / RAND_MAX ) * (election_timeout.tv_sec * 1000
|
||||
+ election_timeout.tv_nsec / 1000000);
|
||||
|
||||
oss.str("");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user