summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShane Kearns <ext-shane.2.kearns@nokia.com>2012-04-27 19:31:37 +0100
committerPasi Pentikäinen <ext-pasi.a.pentikainen@nokia.com>2012-05-10 10:32:20 +0200
commitcc57cd255a923140aed48a4b1211e99966ff8e0b (patch)
tree10c638b9e08e0b665187b4794b892c5a3f0715d7
parentf52aa9ddf44913c112898f384d406525bad6dba4 (diff)
downloadqt4-tools-cc57cd255a923140aed48a4b1211e99966ff8e0b.tar.gz
Use reference count to close down idle network session
QNetworkAccessManager was using the AutoCloseConnection property of QNetworkSession to close it when idle. However this property is only implemented for polling engines and not event driven engines. Instead, release the network session reference. If another request comes in, it will be resurrected from the shared session weak reference. If not, then after 2 minutes when the connection caches are flushed the ref count will reach zero and cause the QNetworkSession to be destroyed (which closes it) Task-number: QTBUG-15812 Task-number: ou1cimx1#997006 Change-Id: I2963bdf13fb02e3ac269489ea463669142f3c5f3 Reviewed-by: Martin Petersson <Martin.Petersson@nokia.com> (cherry picked from commit 1aeaf0e7089c893a927a5ab311a6176aad5874a7) (cherry picked from commit aef97ec5e684f75e4f4e36da1ac321270a1ae2f3) Reviewed-by: Pasi Pentikäinen <ext-pasi.a.pentikainen@nokia.com>
-rw-r--r--src/network/access/qnetworkaccessmanager.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp
index 58690fa6ad..6a701afc68 100644
--- a/src/network/access/qnetworkaccessmanager.cpp
+++ b/src/network/access/qnetworkaccessmanager.cpp
@@ -948,9 +948,6 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera
d->initializeSession = false;
}
}
-
- if (d->networkSession)
- d->networkSession->setSessionProperty(QLatin1String("AutoCloseSessionTimeout"), -1);
#endif
QNetworkRequest request = req;
@@ -1014,8 +1011,11 @@ void QNetworkAccessManagerPrivate::_q_replyFinished()
emit q->finished(reply);
#ifndef QT_NO_BEARERMANAGEMENT
+ // If there are no active requests, release our reference to the network session.
+ // It will not be destroyed immediately, but rather when the connection cache is flushed
+ // after 2 minutes.
if (networkSession && q->findChildren<QNetworkReply *>().count() == 1)
- networkSession->setSessionProperty(QLatin1String("AutoCloseSessionTimeout"), 120000);
+ networkSession.clear();
#endif
}