Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-87264

QHostInfo::fromName() doesn't use DNS-cache

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P3: Somewhat important P3: Somewhat important
    • None
    • 5.12.6
    • Network: DNS
    • None

      By default QHostInfo::fromName() put data to DNS cache, but doesn't use it, turn on use DNS case reduce number of the requests, e.g. at my case this is reduce number of the requests form 13 to 2.

      Patch very simple

      diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp
      index 23b83cf8e6..bf65b9bac0 100644
      --- a/src/network/kernel/qhostinfo.cpp
      +++ b/src/network/kernel/qhostinfo.cpp
      @@ -424,8 +424,12 @@ QHostInfo QHostInfo::fromName(const QString &name)
           qDebug("QHostInfo::fromName(\"%s\")",name.toLatin1().constData());
       #endif
       
      -    QHostInfo hostInfo = QHostInfoAgent::fromName(name);
           QAbstractHostInfoLookupManager* manager = theHostInfoLookupManager();
      +    bool ok = false;
      +    QHostInfo hostInfo = manager->cache.get(name, &ok);
      +    if (ok)
      +        return hostInfo;
      +    hostInfo = QHostInfoAgent::fromName(name);
           manager->cache.put(name, hostInfo);
           return hostInfo;
       }

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            tpochep Timur Pocheptsov
            imb Kirill Brilliantov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes