summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorMarkus Goetz <Markus.Goetz@nokia.com>2010-03-02 09:39:54 (GMT)
committerMarkus Goetz <Markus.Goetz@nokia.com>2010-03-02 10:16:05 (GMT)
commitdaace2df3eb80f1b62f38151f5cc3f3b355927e7 (patch)
tree434c8313e618a8caf9af28a35679aa516c80042b /src/network
parent5a028f794fe48dc7141acedbf0e896b488bb8cd5 (diff)
downloadQt-daace2df3eb80f1b62f38151f5cc3f3b355927e7.zip
Qt-daace2df3eb80f1b62f38151f5cc3f3b355927e7.tar.gz
Qt-daace2df3eb80f1b62f38151f5cc3f3b355927e7.tar.bz2
QAbstractSocket: Use new faster DNS function
Use qt_qhostinfo_lookup which avoids the event loop when the DNS result is already cached. Reviewed-by: Thiago
Diffstat (limited to 'src/network')
-rw-r--r--src/network/socket/qabstractsocket.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp
index 275c436..d990448 100644
--- a/src/network/socket/qabstractsocket.cpp
+++ b/src/network/socket/qabstractsocket.cpp
@@ -354,6 +354,8 @@
#include "qabstractsocket.h"
#include "qabstractsocket_p.h"
+#include "private/qhostinfo_p.h"
+
#include <qabstracteventdispatcher.h>
#include <qdatetime.h>
#include <qhostaddress.h>
@@ -1369,8 +1371,20 @@ void QAbstractSocket::connectToHostImplementation(const QString &hostName, quint
return;
#endif
} else {
- if (d->threadData->eventDispatcher)
- d->hostLookupId = QHostInfo::lookupHost(hostName, this, SLOT(_q_startConnecting(QHostInfo)));
+ if (d->threadData->eventDispatcher) {
+ // this internal API for QHostInfo either immediatly gives us the desired
+ // QHostInfo from cache or later calls the _q_startConnecting slot.
+ bool immediateResultValid = false;
+ QHostInfo hostInfo = qt_qhostinfo_lookup(hostName,
+ this,
+ SLOT(_q_startConnecting(QHostInfo)),
+ &immediateResultValid,
+ &d->hostLookupId);
+ if (immediateResultValid) {
+ d->hostLookupId = -1;
+ d->_q_startConnecting(hostInfo);
+ }
+ }
}
#if defined(QABSTRACTSOCKET_DEBUG)