mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-24 10:52:49 +00:00
kio: avoid going trough internal host cache in PAC helper
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
c35e7f76f3
commit
3723fb8f50
4 changed files with 13 additions and 43 deletions
|
@ -52,8 +52,6 @@ public:
|
|||
HostInfoAgentPrivate();
|
||||
|
||||
QHostInfo lookupHost(const QString &hostName, const unsigned long timeout);
|
||||
QHostInfo lookupCachedHostInfoFor(const QString &hostName);
|
||||
void cacheLookup(const QHostInfo &hostName);
|
||||
|
||||
protected:
|
||||
// reimplementation
|
||||
|
@ -76,16 +74,6 @@ QHostInfo HostInfo::lookupHost(const QString &hostName, unsigned long timeout)
|
|||
return hostInfoAgentPrivate->lookupHost(hostName, timeout);
|
||||
}
|
||||
|
||||
QHostInfo HostInfo::lookupCachedHostInfoFor(const QString& hostName)
|
||||
{
|
||||
return hostInfoAgentPrivate->lookupCachedHostInfoFor(hostName);
|
||||
}
|
||||
|
||||
void HostInfo::cacheLookup(const QHostInfo &info)
|
||||
{
|
||||
hostInfoAgentPrivate->cacheLookup(info);
|
||||
}
|
||||
|
||||
HostInfoAgentPrivate::HostInfoAgentPrivate()
|
||||
: m_dnsCache(HOSTINFO_CACHE_SIZE)
|
||||
{
|
||||
|
@ -106,7 +94,10 @@ QHostInfo HostInfoAgentPrivate::lookupHost(const QString &hostName, unsigned lon
|
|||
}
|
||||
|
||||
// Look up the name in the DNS cache...
|
||||
hostInfo = HostInfo::lookupCachedHostInfoFor(hostName);
|
||||
const HostInfoPair* pair = m_dnsCache.object(hostName);
|
||||
if (pair) {
|
||||
hostInfo = pair->first;
|
||||
}
|
||||
if (!hostInfo.hostName().isEmpty() && hostInfo.error() == QHostInfo::NoError) {
|
||||
return hostInfo;
|
||||
}
|
||||
|
@ -136,29 +127,15 @@ QHostInfo HostInfoAgentPrivate::lookupHost(const QString &hostName, unsigned lon
|
|||
return m_dnsCache.object(hostName)->first;
|
||||
}
|
||||
|
||||
void HostInfoAgentPrivate::cacheLookup(const QHostInfo &info)
|
||||
void HostInfoAgentPrivate::lookupFinished(const QHostInfo &hostInfo)
|
||||
{
|
||||
if (info.hostName().isEmpty() || info.error() != QHostInfo::NoError) {
|
||||
m_lookups.removeAll(hostInfo.lookupId());
|
||||
if (hostInfo.hostName().isEmpty() || hostInfo.error() != QHostInfo::NoError) {
|
||||
return;
|
||||
}
|
||||
QTime expiration = QTime::currentTime();
|
||||
expiration.addSecs(HOSTINFO_EXPIRE_AFTER);
|
||||
m_dnsCache.insert(info.hostName(), new HostInfoPair(info, expiration));
|
||||
}
|
||||
|
||||
QHostInfo HostInfoAgentPrivate::lookupCachedHostInfoFor(const QString& hostName)
|
||||
{
|
||||
const HostInfoPair* pair = m_dnsCache.object(hostName);
|
||||
if (pair) {
|
||||
return pair->first;
|
||||
}
|
||||
return QHostInfo();
|
||||
}
|
||||
|
||||
void HostInfoAgentPrivate::lookupFinished(const QHostInfo &hostInfo)
|
||||
{
|
||||
m_lookups.removeAll(hostInfo.lookupId());
|
||||
cacheLookup(hostInfo);
|
||||
m_dnsCache.insert(hostInfo.hostName(), new HostInfoPair(hostInfo, expiration));
|
||||
}
|
||||
|
||||
void HostInfoAgentPrivate::timerEvent(QTimerEvent *event)
|
||||
|
|
|
@ -29,8 +29,6 @@ namespace KIO
|
|||
namespace HostInfo
|
||||
{
|
||||
KIO_EXPORT QHostInfo lookupHost(const QString& hostName, unsigned long timeout);
|
||||
KIO_EXPORT QHostInfo lookupCachedHostInfoFor(const QString& hostName);
|
||||
KIO_EXPORT void cacheLookup(const QHostInfo& info);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -722,9 +722,9 @@ protected:
|
|||
/**
|
||||
* Performs a DNS lookup for @p hostname and returns the result.
|
||||
*
|
||||
* This function uses the KIO/KHTML DNS cache to speed up the
|
||||
* lookup. It also avoids doing a reverse lookup if the given
|
||||
* host name is already an ip address.
|
||||
* This function uses the KIO DNS cache to speed up the lookup.
|
||||
* It also avoids doing a reverse lookup if the givem host name
|
||||
* is already an IP address.
|
||||
*
|
||||
* \note All uri filter plugins that need to perform a hostname
|
||||
* lookup should use this function.
|
||||
|
@ -735,7 +735,7 @@ protected:
|
|||
*
|
||||
* @since 4.7
|
||||
*/
|
||||
QHostInfo resolveName (const QString& hostname, unsigned long timeout) const;
|
||||
QHostInfo resolveName(const QString& hostname, unsigned long timeout) const;
|
||||
|
||||
private:
|
||||
class KUriFilterPluginPrivate * const d;
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
|
||||
#include <kurl.h>
|
||||
#include <klocalizedstring.h>
|
||||
#include <kio/hostinfo_p.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -168,11 +167,7 @@ namespace
|
|||
// needless reverse lookup
|
||||
QHostAddress address ( host );
|
||||
if ( address.isNull() ) {
|
||||
QHostInfo hostInfo = KIO::HostInfo::lookupCachedHostInfoFor(host);
|
||||
if (hostInfo.hostName().isEmpty() || hostInfo.error() != QHostInfo::NoError) {
|
||||
hostInfo = QHostInfo::fromName(host);
|
||||
KIO::HostInfo::cacheLookup(hostInfo);
|
||||
}
|
||||
QHostInfo hostInfo = QHostInfo::fromName(host);
|
||||
m_addressList = hostInfo.addresses();
|
||||
} else {
|
||||
m_addressList.clear();
|
||||
|
|
Loading…
Add table
Reference in a new issue