Make "CanConnect" timeout configurable in watchdog

* see also https://swift-project.slack.com/archives/G7GD2UP9C/p1522624024000024
* added signatures
* changed timeout
This commit is contained in:
Klaus Basan
2018-04-02 19:32:48 +02:00
parent 9192d13a6c
commit 57b3760b61
4 changed files with 35 additions and 13 deletions

View File

@@ -45,18 +45,19 @@ namespace BlackMisc
return (*this)[i];
}
CUrl CUrlList::getRandomWorkingUrl(int maxTrials) const
CUrl CUrlList::getRandomWorkingUrl(int maxTrials, int timeoutMs) const
{
if (this->isEmpty()) { return CUrl(); }
if (maxTrials < 1) { return CUrl();}
CUrlList trials;
if (timeoutMs < 0) { timeoutMs = CNetworkUtils::getTimeoutMs(); }
for (int t = 0; t < maxTrials && t < this->size(); t++)
{
CUrl url(getRandomWithout(trials));
trials.push_back(url);
QString message;
if (CNetworkUtils::canConnect(url, message)) { return url; }
if (CNetworkUtils::canConnect(url, message, timeoutMs)) { return url; }
}
return CUrl();
}