for(int connectionTimout = 1000; connectionTimout <= MAX_CONN_TIMEOUT; connectionTimout *= 2)
{
QElapsedTimer elapsedTimer;
- const int globalTimout = 2 * MIN_CONNSCORE * connectionTimout;
elapsedTimer.start();
- do
+ const qint64 globalTimeout = 2 * MIN_CONNSCORE * connectionTimout;
+ forever
{
if (mirrorList.isEmpty())
{
const QString hostName = mirrorList.dequeue();
if (tryContactHost(hostName, connectionTimout))
{
- setProgress(1 + (connectionScore += 1));
+ setProgress(1 + (++connectionScore));
if (connectionScore >= MIN_CONNSCORE)
{
goto endLoop; /*success*/
}
else
{
- mirrorList.enqueue(hostName); /*re-schedule*/
+ mirrorList.enqueue(hostName);
+ if(elapsedTimer.hasExpired(globalTimeout))
+ {
+ break; /*timer expired*/
+ }
}
CHECK_CANCELLED();
}
- while(!elapsedTimer.hasExpired(globalTimout));
}
endLoop: