mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
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:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace BlackMisc
|
||||
CUrl getRandomUrl() const;
|
||||
|
||||
//! Random location for distributed load, tested
|
||||
CUrl getRandomWorkingUrl(int maxTrials = 2) const;
|
||||
CUrl getRandomWorkingUrl(int maxTrials = 2, int timeoutMs = -1) const;
|
||||
|
||||
//! Random location for distributed load
|
||||
CUrl getRandomWithout(const CUrlList &exclude) const;
|
||||
|
||||
Reference in New Issue
Block a user