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()]");
|
perror("[Client@connect()]");
|
||||||
m_d->socket.close();
|
m_d->socket.close();
|
||||||
|
|
||||||
std::uniform_real_distribution<> distribution(
|
if (tries > 1) {
|
||||||
CLIENT_RAND_BACKOFF_TSTART, CLIENT_RAND_BACKOFF_TEND);
|
std::uniform_real_distribution<> distribution(
|
||||||
const auto delay = std::chrono::duration<double>(distribution(engine));
|
CLIENT_RAND_BACKOFF_TSTART, CLIENT_RAND_BACKOFF_TEND);
|
||||||
cout << "[Client] Retrying to connect to server in ~" << delay.count()
|
const auto delay = std::chrono::duration<double>(distribution(engine));
|
||||||
<< "s..." << endl;
|
cout << "[Client] Retrying to connect to server in ~" << delay.count()
|
||||||
std::this_thread::sleep_for(delay);
|
<< "s..." << endl;
|
||||||
|
std::this_thread::sleep_for(delay);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cout << "[Client] Unable to reconnect (tried " << CLIENT_RETRY_COUNT
|
cout << "[Client] Unable to reconnect (tried " << CLIENT_RETRY_COUNT
|
||||||
|
|||||||
Reference in New Issue
Block a user