[Qt-interest] DNS caching in Qt
Mandeep Sandhu
mandeepsandhu.chd at gmail.com
Wed Jul 6 10:21:55 CEST 2011
Hi All,
We recently ran into a problem where we were accessing a network
resource but the DNS lookup of the host was continuously failing.
This was on an embedded Linux platform with Qt 4.6.2. We're also
running NetworkManager (0.8) on it. There is a Qt UI app that is used
to access a http URL (on a key press) and display its contents.
The problem used to happen when we tried to access the URL for the
first time while the network was not connected (cable unplugged). At
this time the connection used to fail as expected.
Now, after the network interface is up (i.e after the cable is
plugged-in, NM gets an IP and configures the interface), if we try to
access the same URL 'quickly', i.e very little time difference between
the interface coming up and the app trying to access the URL, we used
to see the DNS lookup failing continuously.
If we keep pressing the key which initiates the n/w request, it would
keep on failing. However, if we wait for around 30 secs and then
access the URL the lookup used to succeed.
I had some questions regarding this behaviour:
* Are DNS lookup failures cached too or only successful resolutions cached?
* I had read in the comment of a bug-report on the Qt bug tracker,
that on Linux, Qt invalidates the cache the moment 'resolv.conf' is
updated. Is this the case? I'm asking this because when this problem
was happening, I had checked the resolv.conf and it was having proper
entries. More so, I could manually do a lookup of the hostname that
was failing and it used to work (all along, the Qt lookup kept
failing). Even manually updating resolv.conf's timestamp did no help.
Thanks,
-mandeep
More information about the Qt-interest-old
mailing list