summaryrefslogtreecommitdiffstats
path: root/src/network/bearer
diff options
context:
space:
mode:
authorShane Kearns <shane.kearns@accenture.com>2011-03-28 16:53:45 (GMT)
committerShane Kearns <shane.kearns@accenture.com>2011-03-29 09:48:26 (GMT)
commitb58eb992f162efc9db6cada9f037f7a0acbe5c57 (patch)
treee36e1631bd8eb6d607c75daeb635fe4b1d014cb3 /src/network/bearer
parentaa67255608d7b752fcdd6fcbabf518dbdbf4f98e (diff)
downloadQt-b58eb992f162efc9db6cada9f037f7a0acbe5c57.zip
Qt-b58eb992f162efc9db6cada9f037f7a0acbe5c57.tar.gz
Qt-b58eb992f162efc9db6cada9f037f7a0acbe5c57.tar.bz2
Ensure shared network session deleted from correct thread
Due to threaded http, the shared QNetworkSession can have its last reference removed from a http delegate thread. To avoid this deadlocking use a deleteLater custom deleter so that the QNS is deleted from the thread it has affinity for. Reviewed-by: Markus Goetz
Diffstat (limited to 'src/network/bearer')
-rw-r--r--src/network/bearer/qsharednetworksession.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/network/bearer/qsharednetworksession.cpp b/src/network/bearer/qsharednetworksession.cpp
index 28ca173..fcb0128 100644
--- a/src/network/bearer/qsharednetworksession.cpp
+++ b/src/network/bearer/qsharednetworksession.cpp
@@ -59,6 +59,11 @@ inline QSharedNetworkSessionManager* sharedNetworkSessionManager()
return rv;
}
+static void doDeleteLater(QObject* obj)
+{
+ obj->deleteLater();
+}
+
QSharedPointer<QNetworkSession> QSharedNetworkSessionManager::getSession(QNetworkConfiguration config)
{
QSharedNetworkSessionManager *m(sharedNetworkSessionManager());
@@ -69,7 +74,7 @@ QSharedPointer<QNetworkSession> QSharedNetworkSessionManager::getSession(QNetwor
return p;
}
//otherwise make one
- QSharedPointer<QNetworkSession> session(new QNetworkSession(config));
+ QSharedPointer<QNetworkSession> session(new QNetworkSession(config), doDeleteLater);
m->sessions[config] = session;
return session;
}