summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorRichard Moore <rich@kde.org>2013-02-04 22:28:59 (GMT)
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-24 13:42:57 (GMT)
commitb59aaa250da6ff22094818b6efe25453f278f42d (patch)
tree8f915f15c4d1ae88bf9570fc75d33b0dc9c49481 /src/network
parent2bba0eadc1570f29331285738b9d319687f84d4c (diff)
downloadQt-b59aaa250da6ff22094818b6efe25453f278f42d.zip
Qt-b59aaa250da6ff22094818b6efe25453f278f42d.tar.gz
Qt-b59aaa250da6ff22094818b6efe25453f278f42d.tar.bz2
Allow QHostInfo::lookupHost() with no receiver to warm the DNS cache.
This change lets you call QHostInfo::lookupHost() with a null receiver in order to warm up the DNS cache. This allows you to try to get the DNS request in flight early. (cherry picked from commit 4030b6339c3dae4474f60b07700526fccf428b0c) Change-Id: Ieac3c535b8f9b12a2f894510a898b349712e2fce Reviewed-by: Richard J. Moore <rich@kde.org> Reviewed-by: Peter Hartmann <phartmann@blackberry.com>
Diffstat (limited to 'src/network')
-rw-r--r--src/network/kernel/qhostinfo.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp
index 70aec36..6380b6e 100644
--- a/src/network/kernel/qhostinfo.cpp
+++ b/src/network/kernel/qhostinfo.cpp
@@ -168,6 +168,9 @@ int QHostInfo::lookupHost(const QString &name, QObject *receiver,
int id = theIdCounter.fetchAndAddRelaxed(1); // generate unique ID
if (name.isEmpty()) {
+ if (!receiver)
+ return -1;
+
QHostInfo hostInfo(id);
hostInfo.setError(QHostInfo::HostNotFound);
hostInfo.setErrorString(QCoreApplication::translate("QHostInfo", "No host name given"));
@@ -188,6 +191,9 @@ int QHostInfo::lookupHost(const QString &name, QObject *receiver,
bool valid = false;
QHostInfo info = manager->cache.get(name, &valid);
if (valid) {
+ if (!receiver)
+ return -1;
+
info.setLookupId(id);
QHostInfoResult result;
QObject::connect(&result, SIGNAL(resultsReady(QHostInfo)), receiver, member, Qt::QueuedConnection);
@@ -198,7 +204,8 @@ int QHostInfo::lookupHost(const QString &name, QObject *receiver,
// cache is not enabled or it was not in the cache, do normal lookup
QHostInfoRunnable* runnable = new QHostInfoRunnable(name, id);
- QObject::connect(&runnable->resultEmitter, SIGNAL(resultsReady(QHostInfo)), receiver, member, Qt::QueuedConnection);
+ if (receiver)
+ QObject::connect(&runnable->resultEmitter, SIGNAL(resultsReady(QHostInfo)), receiver, member, Qt::QueuedConnection);
manager->scheduleLookup(runnable);
}
#else