From ad9e7e0d7757bd59ced29a65362352806426f8f8 Mon Sep 17 00:00:00 2001 From: lordmulder Date: Sun, 2 Feb 2014 15:58:59 +0100 Subject: [PATCH] Bound the maximum number of hosts that will be tested during connectivity test, rather than testing *all* hosts. This avoids that the connectivity test will take VERY long to fail when the Internet connection is actually NOT working. --- src/thread_updater.cpp | 35 +++++++++++++++++------------------ src/version.h | 2 +- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/thread_updater.cpp b/src/thread_updater.cpp index bf5071e..7a80210 100644 --- a/src/thread_updater.cpp +++ b/src/thread_updater.cpp @@ -252,6 +252,7 @@ void UpdateCheckThread::checkForUpdates(void) // ----- Test Internet Connection ----- // int connectionScore = 0; + int maxConnectTries = 2 * MIN_CONNSCORE; log("Checking internet connection..."); setStatus(UpdateStatus_CheckingConnection); @@ -276,28 +277,26 @@ void UpdateCheckThread::checkForUpdates(void) } x264_seed_rand(); - while(!hostList.isEmpty()) + + while(!(hostList.isEmpty() || (connectionScore >= MIN_CONNSCORE) || (--maxConnectTries < 0))) { QString currentHost = hostList.takeAt(x264_rand() % hostList.count()); - if(connectionScore < MIN_CONNSCORE) + log("", "Testing host:", currentHost); + QString outFile = QString("%1/%2.htm").arg(x264_temp_directory(), x264_rand_str()); + bool httpOk = false; + if(getFile(currentHost, outFile, 0, &httpOk)) { - log("", "Testing host:", currentHost); - QString outFile = QString("%1/%2.htm").arg(x264_temp_directory(), x264_rand_str()); - bool httpOk = false; - if(getFile(currentHost, outFile, 0, &httpOk)) - { - connectionScore++; - setProgress(qBound(1, connectionScore + 1, MIN_CONNSCORE + 1)); - x264_sleep(64); - } - if(httpOk) - { - connectionScore++; - setProgress(qBound(1, connectionScore + 1, MIN_CONNSCORE + 1)); - x264_sleep(64); - } - QFile::remove(outFile); + connectionScore++; + setProgress(qBound(1, connectionScore + 1, MIN_CONNSCORE + 1)); + x264_sleep(64); } + if(httpOk) + { + connectionScore++; + setProgress(qBound(1, connectionScore + 1, MIN_CONNSCORE + 1)); + x264_sleep(64); + } + QFile::remove(outFile); } if(connectionScore < MIN_CONNSCORE) diff --git a/src/version.h b/src/version.h index 0387310..ad5e004 100644 --- a/src/version.h +++ b/src/version.h @@ -26,7 +26,7 @@ #define VER_X264_MAJOR 2 #define VER_X264_MINOR 3 #define VER_X264_PATCH 0 -#define VER_X264_BUILD 746 +#define VER_X264_BUILD 750 #define VER_X264_MINIMUM_REV 2380 #define VER_X264_CURRENT_API 142