diff options
author | Peter Hartmann <phartmann@blackberry.com> | 2013-06-11 10:45:41 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-06-24 10:04:14 +0200 |
commit | 48345e5d3c07d6dca12dd4ccee18fa3e0ca0ebda (patch) | |
tree | e1810808ff02ed3d101df29aa6f5593c7c5adead /tests/benchmarks/network | |
parent | a418a544ce1050a85d4a04981e363ce91a8e4211 (diff) |
HTTP internals: do not open too many sockets when preconnecting
Each pair of (normal request, preconnect request) requires only one
socket. E.g. if there is 1 preconnect request in-flight and 2 normal
requests, we need only 2 sockets in total, and not 3.
Therefore, we need to keep track of whether a request is
preconnecting or a normal one.
Task-number: QTBUG-31594
Change-Id: If92ccc35abadfa6090d64ee92bd466615909c94c
Reviewed-by: Richard J. Moore <rich@kde.org>
Diffstat (limited to 'tests/benchmarks/network')
-rw-r--r-- | tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp index 860bd3cf4d..a99fd17a64 100644 --- a/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -463,6 +463,7 @@ private slots: #ifndef QT_NO_SSL void echoPerformance_data(); void echoPerformance(); + void preConnectEncrypted_data(); void preConnectEncrypted(); #endif @@ -476,6 +477,7 @@ private slots: void httpDownloadPerformanceDownloadBuffer(); void httpsRequestChain(); void httpsUpload(); + void preConnect_data(); void preConnect(); private: @@ -548,6 +550,13 @@ void tst_qnetworkreply::echoPerformance() } } +void tst_qnetworkreply::preConnectEncrypted_data() +{ + QTest::addColumn<int>("sleepTime"); + QTest::newRow("2secs") << 2000; // to start a new request after preconnecting is done + QTest::newRow("100ms") << 100; // to start a new request while preconnecting is in-flight +} + void tst_qnetworkreply::preConnectEncrypted() { QString hostName = QLatin1String("www.google.com"); @@ -579,8 +588,9 @@ void tst_qnetworkreply::preConnectEncrypted() manager.clearAccessCache(); // now try to make the connection beforehand + QFETCH(int, sleepTime); manager.connectToHostEncrypted(hostName); - QTestEventLoop::instance().enterLoop(2); + QTestEventLoop::instance().enterLoopMSecs(sleepTime); // now make another request and hopefully use the existing connection QPair<QNetworkReply *, qint64> preConnectResult = runGetRequest(&manager, request); @@ -917,6 +927,11 @@ void tst_qnetworkreply::httpsUpload() } } +void tst_qnetworkreply::preConnect_data() +{ + preConnectEncrypted_data(); +} + void tst_qnetworkreply::preConnect() { QString hostName = QLatin1String("www.google.com"); @@ -948,8 +963,9 @@ void tst_qnetworkreply::preConnect() manager.clearAccessCache(); // now try to make the connection beforehand + QFETCH(int, sleepTime); manager.connectToHost(hostName); - QTestEventLoop::instance().enterLoop(2); + QTestEventLoop::instance().enterLoopMSecs(sleepTime); // now make another request and hopefully use the existing connection QPair<QNetworkReply *, qint64> preConnectResult = runGetRequest(&manager, request); |