From 978dd42d80730fea26ba02303bb65904cfdbadb5 Mon Sep 17 00:00:00 2001 From: Shane Kearns <shane.kearns@accenture.com> Date: Thu, 26 May 2011 13:43:32 +0100 Subject: Enable QTcpServer benchmark on symbian Added required capability to the .pro file Added default connection startup code Removed the QSKIP for IPv6 test Reviewed-by: Markus Goetz --- .../network/socket/qtcpserver/qtcpserver.pro | 2 ++ .../network/socket/qtcpserver/tst_qtcpserver.cpp | 35 +++++++++++++++++++--- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/tests/benchmarks/network/socket/qtcpserver/qtcpserver.pro b/tests/benchmarks/network/socket/qtcpserver/qtcpserver.pro index e5b9346..4bdfcb7 100644 --- a/tests/benchmarks/network/socket/qtcpserver/qtcpserver.pro +++ b/tests/benchmarks/network/socket/qtcpserver/qtcpserver.pro @@ -11,3 +11,5 @@ CONFIG += release # Input SOURCES += tst_qtcpserver.cpp + +symbian:TARGET.CAPABILITY += NetworkServices \ No newline at end of file diff --git a/tests/benchmarks/network/socket/qtcpserver/tst_qtcpserver.cpp b/tests/benchmarks/network/socket/qtcpserver/tst_qtcpserver.cpp index f81853b..9fc5807 100644 --- a/tests/benchmarks/network/socket/qtcpserver/tst_qtcpserver.cpp +++ b/tests/benchmarks/network/socket/qtcpserver/tst_qtcpserver.cpp @@ -54,6 +54,10 @@ #include <qplatformdefs.h> #include <qhostinfo.h> +#include <QNetworkConfiguration> +#include <QNetworkConfigurationManager> +#include <QNetworkSession> + #include <QNetworkProxy> Q_DECLARE_METATYPE(QNetworkProxy) Q_DECLARE_METATYPE(QList<QNetworkProxy>) @@ -75,16 +79,42 @@ public: public slots: void initTestCase_data(); void init(); + void initTestCase(); void cleanup(); private slots: void ipv4LoopbackPerformanceTest(); void ipv6LoopbackPerformanceTest(); void ipv4PerformanceTest(); +private: +#ifndef QT_NO_BEARERMANAGEMENT + QNetworkConfigurationManager *netConfMan; + QNetworkConfiguration networkConfiguration; + QSharedPointer<QNetworkSession> networkSession; +#endif }; tst_QTcpServer::tst_QTcpServer() { - Q_SET_DEFAULT_IAP +} + +void tst_QTcpServer::initTestCase() +{ +#ifndef QT_NO_BEARERMANAGEMENT + netConfMan = new QNetworkConfigurationManager(this); + netConfMan->updateConfigurations(); + connect(netConfMan, SIGNAL(updateCompleted()), &QTestEventLoop::instance(), SLOT(exitLoop())); + QTestEventLoop::instance().enterLoop(10); + networkConfiguration = netConfMan->defaultConfiguration(); + if (networkConfiguration.isValid()) { + networkSession = QSharedPointer<QNetworkSession>(new QNetworkSession(networkConfiguration)); + if (!networkSession->isOpen()) { + networkSession->open(); + QVERIFY(networkSession->waitForOpened(30000)); + } + } else { + QVERIFY(!(netConfMan->capabilities() & QNetworkConfigurationManager::NetworkSessionRequired)); + } +#endif } tst_QTcpServer::~tst_QTcpServer() @@ -179,9 +209,6 @@ void tst_QTcpServer::ipv6LoopbackPerformanceTest() QSKIP("WinCE WM: Not yet supported", SkipAll); #endif -#if defined(Q_OS_SYMBIAN) - QSKIP("Symbian: IPv6 is not yet supported", SkipAll); -#endif QTcpServer server; if (!server.listen(QHostAddress::LocalHostIPv6, 0)) { QVERIFY(server.serverError() == QAbstractSocket::UnsupportedSocketOperationError); -- cgit v0.12 From 9f5809d921f3380c36f482e66184039ec0b0ea93 Mon Sep 17 00:00:00 2001 From: Shane Kearns <shane.kearns@accenture.com> Date: Fri, 10 Jun 2011 19:23:55 +0100 Subject: Symbian QFileSystemWatcher: fix potential crash An address on the stack was being passed to an asynchronous API. This is changed to use the copy of the data on the heap. Reviewed-by: joao --- src/corelib/io/qfilesystemwatcher_symbian.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qfilesystemwatcher_symbian.cpp b/src/corelib/io/qfilesystemwatcher_symbian.cpp index 6e5e911..63cc4f1 100644 --- a/src/corelib/io/qfilesystemwatcher_symbian.cpp +++ b/src/corelib/io/qfilesystemwatcher_symbian.cpp @@ -62,9 +62,9 @@ QNotifyChangeEvent::QNotifyChangeEvent(RFs &fs, const TDesC &file, failureCount(0) { if (isDir) { - fsSession.NotifyChange(ENotifyEntry, iStatus, file); + fsSession.NotifyChange(ENotifyEntry, iStatus, watchedPath); } else { - fsSession.NotifyChange(ENotifyAll, iStatus, file); + fsSession.NotifyChange(ENotifyAll, iStatus, watchedPath); } CActiveScheduler::Add(this); SetActive(); -- cgit v0.12 From 63729b15d4e08401d383f4d38eee6a290e8ba894 Mon Sep 17 00:00:00 2001 From: Shane Kearns <shane.kearns@accenture.com> Date: Thu, 26 May 2011 13:56:02 +0100 Subject: Also test http proxy in the QTcpServer benchmark Test the http socket engine: The test server's proxy will connect to the listening socket on the DUT rather than a listening socket on the proxy server as in the SOCKS5 case. Reviewed-by: Markus Goetz --- tests/benchmarks/network/socket/qtcpserver/tst_qtcpserver.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/benchmarks/network/socket/qtcpserver/tst_qtcpserver.cpp b/tests/benchmarks/network/socket/qtcpserver/tst_qtcpserver.cpp index 9fc5807..f06c4eb 100644 --- a/tests/benchmarks/network/socket/qtcpserver/tst_qtcpserver.cpp +++ b/tests/benchmarks/network/socket/qtcpserver/tst_qtcpserver.cpp @@ -128,6 +128,7 @@ void tst_QTcpServer::initTestCase_data() QTest::newRow("WithoutProxy") << false << 0; QTest::newRow("WithSocks5Proxy") << true << int(QNetworkProxy::Socks5Proxy); + QTest::newRow("WithHttpProxy") << true << int(QNetworkProxy::HttpProxy); } void tst_QTcpServer::init() @@ -263,6 +264,11 @@ void tst_QTcpServer::ipv4PerformanceTest() QTcpServer server; QVERIFY(server.listen(probeSocket.localAddress(), 0)); + QFETCH_GLOBAL(int, proxyType); + //For http proxy, only the active connection can be proxied and not the server socket + if (proxyType == QNetworkProxy::HttpProxy) + QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::HttpProxy, QtNetworkSettings::serverName(), 3128)); + QTcpSocket clientA; clientA.connectToHost(server.serverAddress(), server.serverPort()); QVERIFY(clientA.waitForConnected(5000)); -- cgit v0.12 From 59f186869c67ab51fccf3aac3153629a1da285b7 Mon Sep 17 00:00:00 2001 From: Shane Kearns <shane.kearns@accenture.com> Date: Fri, 10 Jun 2011 19:18:03 +0100 Subject: QFileInfoGatherer: call QFileSystemWatcher addPaths from proper thread QFSW isn't thread safe. With removal of the thread inside QFSW, the addPaths and removePaths must be called from the thread the QFSW was created in. Reviewed-by: joao --- src/gui/dialogs/qfileinfogatherer.cpp | 13 +++++++++---- src/gui/dialogs/qfileinfogatherer_p.h | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/gui/dialogs/qfileinfogatherer.cpp b/src/gui/dialogs/qfileinfogatherer.cpp index 315b931..06c9f39 100644 --- a/src/gui/dialogs/qfileinfogatherer.cpp +++ b/src/gui/dialogs/qfileinfogatherer.cpp @@ -170,7 +170,6 @@ void QFileInfoGatherer::updateFile(const QString &filePath) void QFileInfoGatherer::clear() { #ifndef QT_NO_FILESYSTEMWATCHER - QMutexLocker locker(&mutex); watcher->removePaths(watcher->files()); watcher->removePaths(watcher->directories()); #endif @@ -184,11 +183,18 @@ void QFileInfoGatherer::clear() void QFileInfoGatherer::removePath(const QString &path) { #ifndef QT_NO_FILESYSTEMWATCHER - QMutexLocker locker(&mutex); watcher->removePath(path); #endif } +void QFileInfoGatherer::addPath(const QString &path) +{ +#ifndef QT_NO_FILESYSTEMWATCHER + if (!watcher->directories().contains(path)) + watcher->addPath(path); +#endif +} + /* List all files in \a directoryPath @@ -280,10 +286,9 @@ void QFileInfoGatherer::getFileInfos(const QString &path, const QStringList &fil { #ifndef QT_NO_FILESYSTEMWATCHER if (files.isEmpty() - && !watcher->directories().contains(path) && !path.isEmpty() && !path.startsWith(QLatin1String("//")) /*don't watch UNC path*/) { - watcher->addPath(path); + QMetaObject::invokeMethod(this, "addPath", Q_ARG(QString, path)); } #endif diff --git a/src/gui/dialogs/qfileinfogatherer_p.h b/src/gui/dialogs/qfileinfogatherer_p.h index 98217c1..bff4f69 100644 --- a/src/gui/dialogs/qfileinfogatherer_p.h +++ b/src/gui/dialogs/qfileinfogatherer_p.h @@ -162,6 +162,7 @@ public: void clear(); void removePath(const QString &path); + Q_INVOKABLE void addPath(const QString& path); QExtendedInformation getInfo(const QFileInfo &info) const; public Q_SLOTS: -- cgit v0.12 From 08d1b0ab26dea5749461a988e6168f9dea6081f3 Mon Sep 17 00:00:00 2001 From: Shane Kearns <shane.kearns@accenture.com> Date: Tue, 14 Jun 2011 15:41:50 +0100 Subject: Revert "QFileInfoGatherer: call QFileSystemWatcher addPaths from proper thread" This reverts commit 59f186869c67ab51fccf3aac3153629a1da285b7. Introduced a race condition - QFileInfoGatherer needs a more invasive refactor to solve the thread safety problems. --- src/gui/dialogs/qfileinfogatherer.cpp | 13 ++++--------- src/gui/dialogs/qfileinfogatherer_p.h | 1 - 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/gui/dialogs/qfileinfogatherer.cpp b/src/gui/dialogs/qfileinfogatherer.cpp index 06c9f39..315b931 100644 --- a/src/gui/dialogs/qfileinfogatherer.cpp +++ b/src/gui/dialogs/qfileinfogatherer.cpp @@ -170,6 +170,7 @@ void QFileInfoGatherer::updateFile(const QString &filePath) void QFileInfoGatherer::clear() { #ifndef QT_NO_FILESYSTEMWATCHER + QMutexLocker locker(&mutex); watcher->removePaths(watcher->files()); watcher->removePaths(watcher->directories()); #endif @@ -183,18 +184,11 @@ void QFileInfoGatherer::clear() void QFileInfoGatherer::removePath(const QString &path) { #ifndef QT_NO_FILESYSTEMWATCHER + QMutexLocker locker(&mutex); watcher->removePath(path); #endif } -void QFileInfoGatherer::addPath(const QString &path) -{ -#ifndef QT_NO_FILESYSTEMWATCHER - if (!watcher->directories().contains(path)) - watcher->addPath(path); -#endif -} - /* List all files in \a directoryPath @@ -286,9 +280,10 @@ void QFileInfoGatherer::getFileInfos(const QString &path, const QStringList &fil { #ifndef QT_NO_FILESYSTEMWATCHER if (files.isEmpty() + && !watcher->directories().contains(path) && !path.isEmpty() && !path.startsWith(QLatin1String("//")) /*don't watch UNC path*/) { - QMetaObject::invokeMethod(this, "addPath", Q_ARG(QString, path)); + watcher->addPath(path); } #endif diff --git a/src/gui/dialogs/qfileinfogatherer_p.h b/src/gui/dialogs/qfileinfogatherer_p.h index bff4f69..98217c1 100644 --- a/src/gui/dialogs/qfileinfogatherer_p.h +++ b/src/gui/dialogs/qfileinfogatherer_p.h @@ -162,7 +162,6 @@ public: void clear(); void removePath(const QString &path); - Q_INVOKABLE void addPath(const QString& path); QExtendedInformation getInfo(const QFileInfo &info) const; public Q_SLOTS: -- cgit v0.12