JobClient: fix retry delay
Only wait for the retry delay if really retrying. Change-Id: If12bd3745c799edc5933874d9a44d049646e0e87
This commit is contained in:
@ -83,12 +83,14 @@ bool JobClient::connectToServer()
|
||||
perror("[Client@connect()]");
|
||||
m_d->socket.close();
|
||||
|
||||
std::uniform_real_distribution<> distribution(
|
||||
CLIENT_RAND_BACKOFF_TSTART, CLIENT_RAND_BACKOFF_TEND);
|
||||
const auto delay = std::chrono::duration<double>(distribution(engine));
|
||||
cout << "[Client] Retrying to connect to server in ~" << delay.count()
|
||||
<< "s..." << endl;
|
||||
std::this_thread::sleep_for(delay);
|
||||
if (tries > 1) {
|
||||
std::uniform_real_distribution<> distribution(
|
||||
CLIENT_RAND_BACKOFF_TSTART, CLIENT_RAND_BACKOFF_TEND);
|
||||
const auto delay = std::chrono::duration<double>(distribution(engine));
|
||||
cout << "[Client] Retrying to connect to server in ~" << delay.count()
|
||||
<< "s..." << endl;
|
||||
std::this_thread::sleep_for(delay);
|
||||
}
|
||||
}
|
||||
|
||||
cout << "[Client] Unable to reconnect (tried " << CLIENT_RETRY_COUNT
|
||||
|
||||
Reference in New Issue
Block a user