summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2015-11-23 07:13:00 +0100
committerLiang Qi <liang.qi@theqtcompany.com>2015-11-23 07:13:00 +0100
commit1ed7a67a4cef8350103e4ea33b4bbd084f5d4c2d (patch)
tree03dd7b6f8d9ccc02da6d0d882793ec62c71b00f7 /src/network
parentdbb7817e13bc7f7ccb8f04b00a65eb3dcf8d25f8 (diff)
parent6a2b17eeec2d171d2afa17bdbc36456346bfd13b (diff)
Merge remote-tracking branch 'origin/5.6' into dev
Conflicts: src/corelib/kernel/qcoreapplication.cpp src/corelib/thread/qthread_unix.cpp Change-Id: Ia08d613c3f0bd08cb6dc3e3a57257207dfd4a099
Diffstat (limited to 'src/network')
-rw-r--r--src/network/access/qhttpnetworkconnectionchannel.cpp4
-rw-r--r--src/network/kernel/qhostinfo_winrt.cpp35
-rw-r--r--src/network/kernel/qnetworkinterface_winrt.cpp3
3 files changed, 32 insertions, 10 deletions
diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp
index b4eda3477e..f591abc28b 100644
--- a/src/network/access/qhttpnetworkconnectionchannel.cpp
+++ b/src/network/access/qhttpnetworkconnectionchannel.cpp
@@ -254,6 +254,10 @@ void QHttpNetworkConnectionChannel::handleUnexpectedEOF()
close();
reply->d_func()->errorString = connection->d_func()->errorDetail(QNetworkReply::RemoteHostClosedError, socket);
emit reply->finishedWithError(QNetworkReply::RemoteHostClosedError, reply->d_func()->errorString);
+ reply = 0;
+ if (protocolHandler)
+ protocolHandler->setReply(0);
+ request = QHttpNetworkRequest();
QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);
} else {
reconnectAttempts--;
diff --git a/src/network/kernel/qhostinfo_winrt.cpp b/src/network/kernel/qhostinfo_winrt.cpp
index 3d2344726b..1840bebd39 100644
--- a/src/network/kernel/qhostinfo_winrt.cpp
+++ b/src/network/kernel/qhostinfo_winrt.cpp
@@ -33,6 +33,7 @@
#include "qhostinfo_p.h"
+#include <qfunctions_winrt.h>
#include <qurl.h>
#include <wrl.h>
@@ -49,6 +50,8 @@ using namespace ABI::Windows::Networking::Sockets;
QT_BEGIN_NAMESPACE
+#define E_NO_SUCH_HOST 0x80072af9
+
//#define QHOSTINFO_DEBUG
QHostInfo QHostInfoAgent::fromName(const QString &hostName)
@@ -74,19 +77,22 @@ QHostInfo QHostInfoAgent::fromName(const QString &hostName)
ComPtr<IHostNameFactory> hostnameFactory;
HRESULT hr = RoGetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Networking_HostName).Get(),
IID_PPV_ARGS(&hostnameFactory));
- Q_ASSERT_X(SUCCEEDED(hr), Q_FUNC_INFO, qPrintable(qt_error_string(hr)));
+ Q_ASSERT_SUCCEEDED(hr);
ComPtr<IHostName> host;
HStringReference hostNameRef((const wchar_t*)hostName.utf16());
- hostnameFactory->CreateHostName(hostNameRef.Get(), &host);
+ hr = hostnameFactory->CreateHostName(hostNameRef.Get(), &host);
+ Q_ASSERT_SUCCEEDED(hr);
ComPtr<IDatagramSocketStatics> datagramSocketStatics;
- GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Networking_Sockets_DatagramSocket).Get(), &datagramSocketStatics);
+ hr = GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Networking_Sockets_DatagramSocket).Get(), &datagramSocketStatics);
+ Q_ASSERT_SUCCEEDED(hr);
ComPtr<IAsyncOperation<IVectorView<EndpointPair *> *>> op;
- datagramSocketStatics->GetEndpointPairsAsync(host.Get(),
+ hr = datagramSocketStatics->GetEndpointPairsAsync(host.Get(),
HString::MakeReference(L"0").Get(),
&op);
+ Q_ASSERT_SUCCEEDED(hr);
ComPtr<IVectorView<EndpointPair *>> endpointPairs;
hr = op->GetResults(&endpointPairs);
@@ -98,26 +104,35 @@ QHostInfo QHostInfoAgent::fromName(const QString &hostName)
return results;
}
- if (!endpointPairs)
+ if (hr == E_NO_SUCH_HOST || !endpointPairs) {
+ results.setError(QHostInfo::HostNotFound);
+ results.setErrorString(tr("Host %1 could not be found.").arg(hostName));
return results;
+ }
+ Q_ASSERT_SUCCEEDED(hr);
unsigned int size;
- endpointPairs->get_Size(&size);
+ hr = endpointPairs->get_Size(&size);
+ Q_ASSERT_SUCCEEDED(hr);
QList<QHostAddress> addresses;
for (unsigned int i = 0; i < size; ++i) {
ComPtr<IEndpointPair> endpointpair;
- endpointPairs->GetAt(i, &endpointpair);
+ hr = endpointPairs->GetAt(i, &endpointpair);
+ Q_ASSERT_SUCCEEDED(hr);
ComPtr<IHostName> remoteHost;
- endpointpair->get_RemoteHostName(&remoteHost);
+ hr = endpointpair->get_RemoteHostName(&remoteHost);
+ Q_ASSERT_SUCCEEDED(hr);
if (!remoteHost)
continue;
HostNameType type;
- remoteHost->get_Type(&type);
+ hr = remoteHost->get_Type(&type);
+ Q_ASSERT_SUCCEEDED(hr);
if (type == HostNameType_DomainName)
continue;
HString name;
- remoteHost->get_CanonicalName(name.GetAddressOf());
+ hr = remoteHost->get_CanonicalName(name.GetAddressOf());
+ Q_ASSERT_SUCCEEDED(hr);
UINT32 length;
PCWSTR rawString = name.GetRawBuffer(&length);
QHostAddress addr;
diff --git a/src/network/kernel/qnetworkinterface_winrt.cpp b/src/network/kernel/qnetworkinterface_winrt.cpp
index 18bfcaabda..1e22ab15da 100644
--- a/src/network/kernel/qnetworkinterface_winrt.cpp
+++ b/src/network/kernel/qnetworkinterface_winrt.cpp
@@ -89,6 +89,9 @@ static QNetworkInterfacePrivate *interfaceFromProfile(IConnectionProfile *profil
ComPtr<INetworkAdapter> adapter;
hr = profile->get_NetworkAdapter(&adapter);
+ // Indicates that no internet connection is available/the device is in airplane mode
+ if (hr == E_INVALIDARG)
+ return 0;
Q_ASSERT_SUCCEEDED(hr);
UINT32 type;
hr = adapter->get_IanaInterfaceType(&type);