From cd682bc965d842b10f4138ce5aaf5fb3f0ca0480 Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Sat, 20 Oct 2018 23:43:37 +0200 Subject: [PATCH] Make sure global timeout is *not* triggered, right after tryContactHost() succeeded. --- src/UpdateChecker.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/UpdateChecker.cpp b/src/UpdateChecker.cpp index f91b91d..b665243 100644 --- a/src/UpdateChecker.cpp +++ b/src/UpdateChecker.cpp @@ -227,9 +227,9 @@ void MUtils::UpdateChecker::checkForUpdates(void) 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()) { @@ -238,7 +238,7 @@ void MUtils::UpdateChecker::checkForUpdates(void) const QString hostName = mirrorList.dequeue(); if (tryContactHost(hostName, connectionTimout)) { - setProgress(1 + (connectionScore += 1)); + setProgress(1 + (++connectionScore)); if (connectionScore >= MIN_CONNSCORE) { goto endLoop; /*success*/ @@ -246,11 +246,14 @@ void MUtils::UpdateChecker::checkForUpdates(void) } else { - mirrorList.enqueue(hostName); /*re-schedule*/ + mirrorList.enqueue(hostName); + if(elapsedTimer.hasExpired(globalTimeout)) + { + break; /*timer expired*/ + } } CHECK_CANCELLED(); } - while(!elapsedTimer.hasExpired(globalTimout)); } endLoop: