1
0
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:
Ruben S. Montero 2019-06-25 10:57:31 +02:00
parent 9e18d65ca6
commit bc14442af0
No known key found for this signature in database
GPG Key ID: A0CEA6FA880A1D87

View File

@ -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("");