OSDN Git Service
(root)
/
mutilities
/
MUtilities.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
a6f6264
)
Limit number of connection attempts.
author
LoRd_MuldeR
<mulder2@gmx.de>
Sat, 23 Apr 2016 16:36:19 +0000
(18:36 +0200)
committer
LoRd_MuldeR
<mulder2@gmx.de>
Sat, 23 Apr 2016 16:36:19 +0000
(18:36 +0200)
src/UpdateChecker.cpp
patch
|
blob
|
history
diff --git
a/src/UpdateChecker.cpp
b/src/UpdateChecker.cpp
index
a68b4de
..
fb64ef2
100644
(file)
--- 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
};
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";
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;
static int getMaxProgress(void)
{
int counter = MIN_CONNSCORE + 2;
@@
-321,17
+324,19
@@
void UpdateChecker::checkForUpdates(void)
// ----- Test Known Hosts Connectivity ----- //
// ----- Test Known Hosts Connectivity ----- //
- int connectionScore = 0;
+ int connectionScore = 0
, connectionRetry = MIN_CONNSCORE
;
QStringList hostList = buildRandomList(known_hosts);
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;
if(tryContactHost(hostList.takeFirst()))
{
connectionScore += 1;
+ connectionRetry = MIN_CONNSCORE;
}
setProgress(qBound(1, connectionScore + 1, MIN_CONNSCORE + 1));
}
setProgress(qBound(1, connectionScore + 1, MIN_CONNSCORE + 1));
- msleep(
64
);
+ msleep(
25
);
}
if(connectionScore < MIN_CONNSCORE)
}
if(connectionScore < MIN_CONNSCORE)
@@
-717,7
+722,7
@@
bool UpdateChecker::tryContactHost(const QString &hostname)
return false;
}
return false;
}
- timer.start(
25
000);
+ timer.start(
10
000);
while (process.state() != QProcess::NotRunning)
{
while (process.state() != QProcess::NotRunning)
{