From f30641a7f8c3e38859a6f05a2c190496338b7e7d Mon Sep 17 00:00:00 2001 From: Mandeep Sandhu Date: Tue, 17 Sep 2013 13:04:39 +0530 Subject: [PATCH] Fix error signal supression for failed DNS lookups Sometimes the signal QNetworkReply::error(QNetworkReply::NetworkError) is not emitted for certain requests. This happens under the following conditions: * The hostname provided in the request is incorrect, i.e it will result in a DNS lookup failure. * There is a previous request, for the _same_ host, already pending. The first request that comes for the (incorrect hostname) url, gets enqueued via QHttpNetworkConnectionPrivate::queueRequest(). Here, after starting a DNS lookup, we mark the network state of this connection as - "InProgress". Now, if a second reuest comes for the same host, we use the existing HTTP connection object as it's present in the cache. However, when enqueing the request (in queueRequest()), we see that the network is NOT in "Unknown" state and return immediately without adding this new request to the list of pending lookups (via QHostInfo::lookupHost()). To fix this issue, we should queue incoming lookup requests, even if the current (HTTP) connection is in the "InProgress" state, so that we can inform the requestor of a failed lookup. Since QHostInfo::lookupHost() handles lookups for duplicate hostnames properly, things should be fine even if multiple requests for the same host have been enqueued. Task-number: QTBUG-32911 Change-Id: I6a9c8430121e9a5a2d45983b6bda70c324437992 Reviewed-by: Peter Hartmann --- src/network/access/qhttpnetworkconnection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index b6a3b5e3ab..ba9e5cbdc4 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -560,7 +560,7 @@ QHttpNetworkReply* QHttpNetworkConnectionPrivate::queueRequest(const QHttpNetwor // untill we have started the first connection attempt. So no // request will be started untill we know if IPv4 or IPv6 // should be used. - if (networkLayerState == Unknown) { + if (networkLayerState == Unknown || networkLayerState == InProgress) { startHostInfoLookup(); } else if ( networkLayerState == IPv4 || networkLayerState == IPv6 ) { // this used to be called via invokeMethod and a QueuedConnection