summaryrefslogtreecommitdiffstats
path: root/src/network/socket/qnativesocketengine_winrt.cpp
diff options
context:
space:
mode:
authorOliver Wolff <oliver.wolff@theqtcompany.com>2016-10-13 13:59:44 +0200
committerOliver Wolff <oliver.wolff@qt.io>2016-10-20 07:02:10 +0000
commit0e61323c87490ea3991f7b6211034285ce5a932f (patch)
treebcb2ed53a6c079f6832cc3d34485cd307fb99d17 /src/network/socket/qnativesocketengine_winrt.cpp
parent2c0033983bc53e906eab3f4b2fae836ff8472713 (diff)
winrt: Added timeout for cancellation of socket read operation
As the function runs on the XAML thread it can make the app unresponsive/wait forever on a socket close. Thus we should not wait forever but have a timeout. If the timeout is hit the socket is not closed properly but hard reset. Change-Id: I82e9425c0f8195e3465027fdc2417a93f1c1ad91 Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Diffstat (limited to 'src/network/socket/qnativesocketengine_winrt.cpp')
-rw-r--r--src/network/socket/qnativesocketengine_winrt.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/network/socket/qnativesocketengine_winrt.cpp b/src/network/socket/qnativesocketengine_winrt.cpp
index 58f0668854..b6a739d1b8 100644
--- a/src/network/socket/qnativesocketengine_winrt.cpp
+++ b/src/network/socket/qnativesocketengine_winrt.cpp
@@ -492,10 +492,12 @@ void QNativeSocketEngine::close()
ComPtr<IAsyncAction> action;
hr = socket3->CancelIOAsync(&action);
Q_ASSERT_SUCCEEDED(hr);
- hr = QWinRTFunctions::await(action);
+ hr = QWinRTFunctions::await(action, QWinRTFunctions::YieldThread, 5000);
// If there is no pending IO (no read established before) the function will fail with
// "function was called at an unexpected time" which is fine.
- if (hr != E_ILLEGAL_METHOD_CALL)
+ // Timeout is fine as well. The result will be the socket being hard reset instead of
+ // being closed gracefully
+ if (hr != E_ILLEGAL_METHOD_CALL && hr != ERROR_TIMEOUT)
Q_ASSERT_SUCCEEDED(hr);
return S_OK;
});