From 1087c599e879ee072701909f6ea01b6f06be2798 Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Sat, 23 Apr 2016 18:36:19 +0200 Subject: [PATCH] Limit number of connection attempts. --- src/UpdateChecker.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/UpdateChecker.cpp b/src/UpdateChecker.cpp index a68b4de..fb64ef2 100644 --- a/src/UpdateChecker.cpp +++ b/src/UpdateChecker.cpp @@ -196,11 +196,14 @@ static const char *known_hosts[] = //Taken form: http://www.alexa.com/topsites NULL }; -static const int MIN_CONNSCORE = 8; +static const int MIN_CONNSCORE = 5; static const int VERSION_INFO_EXPIRES_MONTHS = 6; static char *USER_AGENT_STR = "Mozilla/5.0 (X11; Linux i686; rv:7.0.1) Gecko/20111106 IceCat/7.0.1"; -//Helper function +//////////////////////////////////////////////////////////// +// Helper Functions +//////////////////////////////////////////////////////////// + static int getMaxProgress(void) { int counter = MIN_CONNSCORE + 2; @@ -321,17 +324,19 @@ void UpdateChecker::checkForUpdates(void) // ----- Test Known Hosts Connectivity ----- // - int connectionScore = 0; + int connectionScore = 0, connectionRetry = MIN_CONNSCORE; QStringList hostList = buildRandomList(known_hosts); - while(!(hostList.isEmpty() || (connectionScore >= MIN_CONNSCORE))) + while((!hostList.isEmpty()) && (connectionScore < MIN_CONNSCORE) && (connectionRetry > 0)) { + connectionRetry--; if(tryContactHost(hostList.takeFirst())) { connectionScore += 1; + connectionRetry = MIN_CONNSCORE; } setProgress(qBound(1, connectionScore + 1, MIN_CONNSCORE + 1)); - msleep(64); + msleep(25); } if(connectionScore < MIN_CONNSCORE) @@ -717,7 +722,7 @@ bool UpdateChecker::tryContactHost(const QString &hostname) return false; } - timer.start(25000); + timer.start(10000); while (process.state() != QProcess::NotRunning) {