JobClient: fix retry delay

Only wait for the retry delay if really retrying.

Change-Id: If12bd3745c799edc5933874d9a44d049646e0e87
This commit is contained in:
Horst Schirmeier
2018-08-01 14:14:11 +02:00
parent 00882f98ad
commit 1c774ce50d

View File

@ -83,6 +83,7 @@ bool JobClient::connectToServer()
perror("[Client@connect()]");
m_d->socket.close();
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));
@ -90,6 +91,7 @@ bool JobClient::connectToServer()
<< "s..." << endl;
std::this_thread::sleep_for(delay);
}
}
cout << "[Client] Unable to reconnect (tried " << CLIENT_RETRY_COUNT
<< " times); I'll give it up!" << endl;