diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-10-24 12:48:39 +0200 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-10-24 12:48:42 +0200 |
commit | 840f6a40e6218992b5b9d451ee3c0886a4846c89 (patch) | |
tree | 2b808decc7adf5218b810d2de6b45c5a8b4cfc42 /src/network | |
parent | 109bf980b37fed405c6c1eb14cb9c83ff897e389 (diff) | |
parent | 2e3870fe37d36ccf4bd84eb90e1d5e08ad00c1bc (diff) |
Merge remote-tracking branch 'origin/stable' into dev
Change-Id: Ie56539b2e0be611a363b5f15ae5412a78d6945a2
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/access/qhttpnetworkconnection.cpp | 18 | ||||
-rw-r--r-- | src/network/access/qhttpnetworkconnection_p.h | 5 | ||||
-rw-r--r-- | src/network/access/qhttpnetworkconnectionchannel.cpp | 4 | ||||
-rw-r--r-- | src/network/kernel/qdnslookup_unix.cpp | 15 | ||||
-rw-r--r-- | src/network/kernel/qhostinfo_unix.cpp | 15 |
5 files changed, 41 insertions, 16 deletions
diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index ba9e5cbdc4..e0996c4072 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -181,7 +181,7 @@ int QHttpNetworkConnectionPrivate::indexOf(QAbstractSocket *socket) const return 0; } -// If the connection is in the InProgress state channel errors should not always be +// If the connection is in the HostLookupPendening state channel errors should not always be // emitted. This function will check the status of the connection channels if we // have not decided the networkLayerState and will return true if the channel error // should be emitted by the channel. @@ -200,12 +200,12 @@ bool QHttpNetworkConnectionPrivate::shouldEmitChannelError(QAbstractSocket *sock } if (channelCount == 1) { - if (networkLayerState == QHttpNetworkConnectionPrivate::InProgress) + if (networkLayerState == HostLookupPending || networkLayerState == IPv4or6) networkLayerState = QHttpNetworkConnectionPrivate::Unknown; channels[0].close(); emitError = true; } else { - if (networkLayerState == QHttpNetworkConnectionPrivate::InProgress) { + if (networkLayerState == HostLookupPending || networkLayerState == IPv4or6) { if (channels[otherSocket].isSocketBusy() && (channels[otherSocket].state != QHttpNetworkConnectionChannel::ClosingState)) { // this was the first socket to fail. channels[i].close(); @@ -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 || networkLayerState == InProgress) { + if (networkLayerState == Unknown || networkLayerState == HostLookupPending) { startHostInfoLookup(); } else if ( networkLayerState == IPv4 || networkLayerState == IPv6 ) { // this used to be called via invokeMethod and a QueuedConnection @@ -878,7 +878,7 @@ void QHttpNetworkConnectionPrivate::removeReply(QHttpNetworkReply *reply) void QHttpNetworkConnectionPrivate::_q_startNextRequest() { // If there is no network layer state decided we should not start any new requests. - if (networkLayerState == Unknown || networkLayerState == InProgress) + if (networkLayerState == Unknown || networkLayerState == HostLookupPending || networkLayerState == IPv4or6) return; // If the QHttpNetworkConnection is currently paused then bail out immediately @@ -986,7 +986,7 @@ void QHttpNetworkConnectionPrivate::readMoreLater(QHttpNetworkReply *reply) // lookup as then the hostinfo will already be in the cache. void QHttpNetworkConnectionPrivate::startHostInfoLookup() { - networkLayerState = InProgress; + networkLayerState = HostLookupPending; // check if we already now can decide if this is IPv4 or IPv6 QString lookupHost = hostName; @@ -1028,6 +1028,8 @@ void QHttpNetworkConnectionPrivate::_q_hostLookupFinished(QHostInfo info) bool bIpv4 = false; bool bIpv6 = false; bool foundAddress = false; + if (networkLayerState == IPv4 || networkLayerState == IPv6 || networkLayerState == IPv4or6) + return; foreach (const QHostAddress &address, info.addresses()) { if (address.protocol() == QAbstractSocket::IPv4Protocol) { @@ -1077,7 +1079,7 @@ void QHttpNetworkConnectionPrivate::startNetworkLayerStateLookup() Q_ASSERT(!channels[0].isSocketBusy()); Q_ASSERT(!channels[1].isSocketBusy()); - networkLayerState = InProgress; + networkLayerState = IPv4or6; channels[0].networkLayerPreference = QAbstractSocket::IPv4Protocol; channels[1].networkLayerPreference = QAbstractSocket::IPv6Protocol; @@ -1101,7 +1103,7 @@ void QHttpNetworkConnectionPrivate::startNetworkLayerStateLookup() else channels[0].ensureConnection(); } else { - networkLayerState = InProgress; + networkLayerState = IPv4or6; channels[0].networkLayerPreference = QAbstractSocket::AnyIPProtocol; channels[0].ensureConnection(); } diff --git a/src/network/access/qhttpnetworkconnection_p.h b/src/network/access/qhttpnetworkconnection_p.h index c54250f6ed..2aaaad24ac 100644 --- a/src/network/access/qhttpnetworkconnection_p.h +++ b/src/network/access/qhttpnetworkconnection_p.h @@ -165,9 +165,10 @@ public: enum NetworkLayerPreferenceState { Unknown, - InProgress, + HostLookupPending, IPv4, - IPv6 + IPv6, + IPv4or6 }; QHttpNetworkConnectionPrivate(const QString &hostName, quint16 port, bool encrypt); diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index da82fdf8d2..6e786893ed 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -1045,7 +1045,7 @@ void QHttpNetworkConnectionChannel::_q_disconnected() void QHttpNetworkConnectionChannel::_q_connected() { // For the Happy Eyeballs we need to check if this is the first channel to connect. - if (connection->d_func()->networkLayerState == QHttpNetworkConnectionPrivate::InProgress) { + if (connection->d_func()->networkLayerState == QHttpNetworkConnectionPrivate::HostLookupPending || connection->d_func()->networkLayerState == QHttpNetworkConnectionPrivate::IPv4or6) { if (connection->d_func()->delayedConnectionTimer.isActive()) connection->d_func()->delayedConnectionTimer.stop(); if (networkLayerPreference == QAbstractSocket::IPv4Protocol) @@ -1212,7 +1212,7 @@ void QHttpNetworkConnectionChannel::_q_error(QAbstractSocket::SocketError socket QPointer<QHttpNetworkConnection> that = connection; QString errorString = connection->d_func()->errorDetail(errorCode, socket, socket->errorString()); - // In the InProgress state the channel should not emit the error. + // In the HostLookupPending state the channel should not emit the error. // This will instead be handled by the connection. if (!connection->d_func()->shouldEmitChannelError(socket)) return; diff --git a/src/network/kernel/qdnslookup_unix.cpp b/src/network/kernel/qdnslookup_unix.cpp index 729729d929..052c492f07 100644 --- a/src/network/kernel/qdnslookup_unix.cpp +++ b/src/network/kernel/qdnslookup_unix.cpp @@ -52,6 +52,10 @@ #include <arpa/nameser_compat.h> #include <resolv.h> +#ifdef __GNU_LIBRARY__ +# include <gnu/lib-names.h> +#endif + QT_BEGIN_NAMESPACE #ifndef QT_NO_LIBRARY @@ -77,9 +81,16 @@ struct QDnsLookupStateDeleter static void resolveLibrary() { - QLibrary lib(QLatin1String("resolv")); + QLibrary lib; +#ifdef LIBRESOLV_SO + lib.setFileName(QStringLiteral(LIBRESOLV_SO)); if (!lib.load()) - return; +#endif + { + lib.setFileName(QLatin1String("resolv")); + if (!lib.load()) + return; + } local_dn_expand = dn_expand_proto(lib.resolve("__dn_expand")); if (!local_dn_expand) diff --git a/src/network/kernel/qhostinfo_unix.cpp b/src/network/kernel/qhostinfo_unix.cpp index 04daf2ecdd..dc2702b552 100644 --- a/src/network/kernel/qhostinfo_unix.cpp +++ b/src/network/kernel/qhostinfo_unix.cpp @@ -63,6 +63,10 @@ # include <resolv.h> #endif +#ifdef __GNU_LIBRARY__ +# include <gnu/lib-names.h> +#endif + #if defined (QT_NO_GETADDRINFO) static QBasicMutex getHostByNameMutex; #endif @@ -93,9 +97,16 @@ static res_state_ptr local_res = 0; static void resolveLibrary() { #if !defined(QT_NO_LIBRARY) && !defined(Q_OS_QNX) - QLibrary lib(QLatin1String("resolv")); + QLibrary lib; +#ifdef LIBRESOLV_SO + lib.setFileName(QStringLiteral(LIBRESOLV_SO)); if (!lib.load()) - return; +#endif + { + lib.setFileName(QLatin1String("resolv")); + if (!lib.load()) + return; + } local_res_init = res_init_proto(lib.resolve("__res_init")); if (!local_res_init) |