Commit eba979f6 authored by Oliver Wolff's avatar Oliver Wolff Committed by Jani Heikkinen
Browse files

WinRT: Do not try to cancel IO for udp sockets on socket close


As the functionality is not available for udp sockets trying to
call it will cause a crash on socket close.

Task-number: QTBUG-53424
Change-Id: Id80b36a248d12bf360135b2374c0a0efdab3a1f0
Reviewed-by: default avatarMaurice Kalinowski <maurice.kalinowski@qt.io>
Showing with 12 additions and 10 deletions
......@@ -458,17 +458,19 @@ void QNativeSocketEngine::close()
}
#if _MSC_VER >= 1900
// To close the connection properly (not with a hard reset) all pending read operation have to
// be finished or cancelled. The API isn't available on Windows 8.1 though.
ComPtr<IStreamSocket3> socket3;
hr = d->tcpSocket()->QueryInterface(IID_PPV_ARGS(&socket3));
Q_ASSERT_SUCCEEDED(hr);
if (d->socketType == QAbstractSocket::TcpSocket) {
// To close the connection properly (not with a hard reset) all pending read operation have to
// be finished or cancelled. The API isn't available on Windows 8.1 though.
ComPtr<IStreamSocket3> socket3;
hr = d->tcpSocket()->QueryInterface(IID_PPV_ARGS(&socket3));
Q_ASSERT_SUCCEEDED(hr);
ComPtr<IAsyncAction> action;
hr = socket3->CancelIOAsync(&action);
Q_ASSERT_SUCCEEDED(hr);
hr = QWinRTFunctions::await(action);
Q_ASSERT_SUCCEEDED(hr);
ComPtr<IAsyncAction> action;
hr = socket3->CancelIOAsync(&action);
Q_ASSERT_SUCCEEDED(hr);
hr = QWinRTFunctions::await(action);
Q_ASSERT_SUCCEEDED(hr);
}
#endif // _MSC_VER >= 1900
if (d->readOp) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment