diff options
author | aavit <qt-info@nokia.com> | 2011-01-14 13:06:56 (GMT) |
---|---|---|
committer | aavit <qt-info@nokia.com> | 2011-01-14 13:06:56 (GMT) |
commit | ce089742eb9caed768beed0ae68b2623a9cdf2ca (patch) | |
tree | 2b6f472f8904e56152e9a3d0d7fea1e5ca60f157 /tests/arthur | |
parent | 1287c134594cbb173857e62229eccefbefd2d412 (diff) | |
download | Qt-ce089742eb9caed768beed0ae68b2623a9cdf2ca.zip Qt-ce089742eb9caed768beed0ae68b2623a9cdf2ca.tar.gz Qt-ce089742eb9caed768beed0ae68b2623a9cdf2ca.tar.bz2 |
Avoid runId clashes
Diffstat (limited to 'tests/arthur')
-rw-r--r-- | tests/arthur/baselineserver/src/baselineserver.cpp | 40 | ||||
-rw-r--r-- | tests/arthur/baselineserver/src/baselineserver.h | 10 | ||||
-rw-r--r-- | tests/arthur/baselineserver/src/main.cpp | 2 |
3 files changed, 32 insertions, 20 deletions
diff --git a/tests/arthur/baselineserver/src/baselineserver.cpp b/tests/arthur/baselineserver/src/baselineserver.cpp index d72f2e3..8aaa8ff 100644 --- a/tests/arthur/baselineserver/src/baselineserver.cpp +++ b/tests/arthur/baselineserver/src/baselineserver.cpp @@ -53,16 +53,16 @@ #include <QProcess> #include <QDirIterator> -QString BaselineServer::storage; - // extra fields, for use in image metadata storage const QString PI_ImageChecksum(QLS("ImageChecksum")); const QString PI_RunId(QLS("RunId")); const QString PI_CreationDate(QLS("CreationDate")); +QString BaselineServer::storage; +QString BaselineServer::url; BaselineServer::BaselineServer(QObject *parent) - : QTcpServer(parent) + : QTcpServer(parent), lastRunIdIdx(0) { QFileInfo me(QCoreApplication::applicationFilePath()); meLastMod = me.lastModified(); @@ -76,22 +76,32 @@ QString BaselineServer::storagePath() if (storage.isEmpty()) { storage = QLS(qgetenv("QT_LANCELOT_DIR")); if (storage.isEmpty()) - storage = QLS("/var/www"); + storage = QLS("/var/www"); } return storage; } QString BaselineServer::baseUrl() { - return QLS("http://") - + QHostInfo::localHostName().toLatin1() + '.' - + QHostInfo::localDomainName().toLatin1() + '/'; + if (url.isEmpty()) { + url = QLS("http://") + + QHostInfo::localHostName().toLatin1() + '.' + + QHostInfo::localDomainName().toLatin1() + '/'; + } + return url; } void BaselineServer::incomingConnection(int socketDescriptor) { - qDebug() << "Server: New connection!"; - BaselineThread *thread = new BaselineThread(socketDescriptor, this); + QString runId = QDateTime::currentDateTime().toString(QLS("MMMdd-hhmmss")); + if (runId == lastRunId) { + runId += QLC('-') + QString::number(++lastRunIdIdx); + } else { + lastRunId = runId; + lastRunIdIdx = 0; + } + qDebug() << "Server: New connection! RunId:" << runId; + BaselineThread *thread = new BaselineThread(runId, socketDescriptor, this); connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); thread->start(); } @@ -119,23 +129,21 @@ void BaselineServer::heartbeat() QCoreApplication::exit(); } -BaselineThread::BaselineThread(int socketDescriptor, QObject *parent) - : QThread(parent), socketDescriptor(socketDescriptor) +BaselineThread::BaselineThread(const QString &runId, int socketDescriptor, QObject *parent) + : QThread(parent), runId(runId), socketDescriptor(socketDescriptor) { } void BaselineThread::run() { - BaselineHandler handler(socketDescriptor); + BaselineHandler handler(runId, socketDescriptor); exec(); } -BaselineHandler::BaselineHandler(int socketDescriptor) - : QObject(), connectionEstablished(false) +BaselineHandler::BaselineHandler(const QString &runId, int socketDescriptor) + : QObject(), runId(runId), connectionEstablished(false) { - runId = QDateTime::currentDateTime().toString(QLS("MMMdd-hhmmss")); - if (socketDescriptor == -1) return; diff --git a/tests/arthur/baselineserver/src/baselineserver.h b/tests/arthur/baselineserver/src/baselineserver.h index 1409afc..a5683b2 100644 --- a/tests/arthur/baselineserver/src/baselineserver.h +++ b/tests/arthur/baselineserver/src/baselineserver.h @@ -75,7 +75,10 @@ private slots: private: QTimer *heartbeatTimer; QDateTime meLastMod; + QString lastRunId; + int lastRunIdIdx; static QString storage; + static QString url; }; @@ -85,10 +88,11 @@ class BaselineThread : public QThread Q_OBJECT public: - BaselineThread(int socketDescriptor, QObject *parent); + BaselineThread(const QString &runId, int socketDescriptor, QObject *parent); void run(); private: + QString runId; int socketDescriptor; }; @@ -98,7 +102,7 @@ class BaselineHandler : public QObject Q_OBJECT public: - BaselineHandler(int socketDescriptor = -1); + BaselineHandler(const QString &runId, int socketDescriptor = -1); void testPathMapping(); QString pathForItem(const ImageItem &item, bool isBaseline = true, bool absolute = true) const; @@ -125,8 +129,8 @@ private: BaselineProtocol proto; PlatformInfo plat; mutable PlatformInfo mapped; - bool connectionEstablished; QString runId; + bool connectionEstablished; Report report; }; diff --git a/tests/arthur/baselineserver/src/main.cpp b/tests/arthur/baselineserver/src/main.cpp index bf41f41..02fc2fa 100644 --- a/tests/arthur/baselineserver/src/main.cpp +++ b/tests/arthur/baselineserver/src/main.cpp @@ -53,7 +53,7 @@ int main(int argc, char *argv[]) } if (a.arguments().contains(QLatin1String("-testmapping"))) { - BaselineHandler h; + BaselineHandler h(QLS("SomeRunId")); h.testPathMapping(); return 0; } |