From 7261fcae4a8860a6afe5c570a1851db6caa2dddb Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Tue, 4 Oct 2016 14:35:23 -0700 Subject: [PATCH 1/8] possible fix for domain-server crash-on-exit --- libraries/shared/src/SettingInterface.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libraries/shared/src/SettingInterface.cpp b/libraries/shared/src/SettingInterface.cpp index 95c6bc1efc..9db84055f7 100644 --- a/libraries/shared/src/SettingInterface.cpp +++ b/libraries/shared/src/SettingInterface.cpp @@ -34,7 +34,6 @@ namespace Setting { DependencyManager::destroy(); // - globalManager->deleteLater(); globalManager.reset(); // quit the settings manager thread and wait on it to make sure it's gone @@ -72,9 +71,9 @@ namespace Setting { globalManager = DependencyManager::set(); - QObject::connect(globalManager.data(), SIGNAL(destroyed()), thread, SLOT(quit())); QObject::connect(thread, SIGNAL(started()), globalManager.data(), SLOT(startTimer())); QObject::connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); + QObject::connect(thread, SIGNAL(finished()), globalManager.data(), SLOT(deleteLater())); globalManager->moveToThread(thread); thread->start(); qCDebug(shared) << "Settings thread started."; From e9196e8f62925d59b079f2a90c30ced02701c34e Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 5 Oct 2016 13:41:15 -0700 Subject: [PATCH 2/8] testing client to check if domain-server and ACs are running --- tools/CMakeLists.txt | 3 + tools/ac-client/CMakeLists.txt | 3 + tools/ac-client/src/ACClientApp.cpp | 272 ++++++++++++++++++++++++++++ tools/ac-client/src/ACClientApp.h | 55 ++++++ tools/ac-client/src/main.cpp | 23 +++ 5 files changed, 356 insertions(+) create mode 100644 tools/ac-client/CMakeLists.txt create mode 100644 tools/ac-client/src/ACClientApp.cpp create mode 100644 tools/ac-client/src/ACClientApp.h create mode 100644 tools/ac-client/src/main.cpp diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index a077efc335..cf0e25a757 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -10,3 +10,6 @@ set_target_properties(vhacd-util PROPERTIES FOLDER "Tools") add_subdirectory(ice-client) set_target_properties(ice-client PROPERTIES FOLDER "Tools") + +add_subdirectory(ac-client) +set_target_properties(ac-client PROPERTIES FOLDER "Tools") diff --git a/tools/ac-client/CMakeLists.txt b/tools/ac-client/CMakeLists.txt new file mode 100644 index 0000000000..9e623b02e9 --- /dev/null +++ b/tools/ac-client/CMakeLists.txt @@ -0,0 +1,3 @@ +set(TARGET_NAME ac-client) +setup_hifi_project(Core Widgets) +link_hifi_libraries(shared networking) diff --git a/tools/ac-client/src/ACClientApp.cpp b/tools/ac-client/src/ACClientApp.cpp new file mode 100644 index 0000000000..3ea2322ffd --- /dev/null +++ b/tools/ac-client/src/ACClientApp.cpp @@ -0,0 +1,272 @@ +// +// ACClientApp.cpp +// tools/ac-client/src +// +// Created by Seth Alves on 2016-10-5 +// Copyright 2015 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "ACClientApp.h" + +ACClientApp::ACClientApp(int argc, char* argv[]) : + QCoreApplication(argc, argv) +{ + // parse command-line + QCommandLineParser parser; + parser.setApplicationDescription("High Fidelity AC client"); + parser.addHelpOption(); + + const QCommandLineOption helpOption = parser.addHelpOption(); + + const QCommandLineOption verboseOutput("v", "verbose output"); + parser.addOption(verboseOutput); + + const QCommandLineOption domainAddressOption("d", "domain-server address", "127.0.0.1"); + parser.addOption(domainAddressOption); + + const QCommandLineOption cacheSTUNOption("s", "cache stun-server response"); + parser.addOption(cacheSTUNOption); + + const QCommandLineOption listenPortOption("listenPort", "listen port", QString::number(INVALID_PORT)); + parser.addOption(listenPortOption); + + + if (!parser.parse(QCoreApplication::arguments())) { + qCritical() << parser.errorText() << endl; + parser.showHelp(); + Q_UNREACHABLE(); + } + + if (parser.isSet(helpOption)) { + parser.showHelp(); + Q_UNREACHABLE(); + } + + _verbose = parser.isSet(verboseOutput); + if (!_verbose) { + QLoggingCategory::setFilterRules("qt.network.ssl.warning=false"); + + const_cast(&networking())->setEnabled(QtDebugMsg, false); + const_cast(&networking())->setEnabled(QtInfoMsg, false); + const_cast(&networking())->setEnabled(QtWarningMsg, false); + + const_cast(&shared())->setEnabled(QtDebugMsg, false); + const_cast(&shared())->setEnabled(QtInfoMsg, false); + const_cast(&shared())->setEnabled(QtWarningMsg, false); + } + + // QString domainServerAddress = "127.0.0.1"; + // if (parser.isSet(domainAddressOption)) { + // // parse the IP and port combination for this target + // QString hostnamePortString = parser.value(domainAddressOption); + + // QHostAddress address { hostnamePortString.left(hostnamePortString.indexOf(':')) }; + // quint16 port { (quint16) hostnamePortString.mid(hostnamePortString.indexOf(':') + 1).toUInt() }; + // if (port == 0) { + // port = DEFAULT_DOMAIN_SERVER_PORT; + // } + + // if (address.isNull()) { + // qCritical() << "Could not parse an IP address and port combination from" << hostnamePortString << "-" << + // "The parsed IP was" << address.toString() << "and the parsed port was" << port; + + // QMetaObject::invokeMethod(this, "quit", Qt::QueuedConnection); + // } else { + // _iceServerAddr = HifiSockAddr(address, port); + // } + + // if (_verbose) { + // qDebug() << "domain-server Address is" << domainServerAddress << "port is" << port; + // } + // } + + QString domainServerAddress = "127.0.0.1:40103"; + if (parser.isSet(domainAddressOption)) { + domainServerAddress = parser.value(domainAddressOption); + } + + if (_verbose) { + qDebug() << "domain-server address is" << domainServerAddress; + } + + int listenPort = INVALID_PORT; + if (parser.isSet(listenPortOption)) { + listenPort = parser.value(listenPortOption).toInt(); + } + + Setting::preInit(); + DependencyManager::registerInheritance(); + // DependencyManager::registerInheritance(); + Setting::init(); + + DependencyManager::set([&]{ return QString("Mozilla/5.0 (HighFidelityACClient)"); }); + DependencyManager::set(); + DependencyManager::set(NodeType::Agent, listenPort); + + + auto nodeList = DependencyManager::get(); + + // start the nodeThread so its event loop is running + QThread* nodeThread = new QThread(this); + nodeThread->setObjectName("NodeList Thread"); + nodeThread->start(); + + // make sure the node thread is given highest priority + nodeThread->setPriority(QThread::TimeCriticalPriority); + + // setup a timer for domain-server check ins + QTimer* domainCheckInTimer = new QTimer(nodeList.data()); + connect(domainCheckInTimer, &QTimer::timeout, nodeList.data(), &NodeList::sendDomainServerCheckIn); + domainCheckInTimer->start(DOMAIN_SERVER_CHECK_IN_MSECS); + + // put the NodeList and datagram processing on the node thread + nodeList->moveToThread(nodeThread); + + + const DomainHandler& domainHandler = nodeList->getDomainHandler(); + + connect(&domainHandler, SIGNAL(hostnameChanged(const QString&)), SLOT(domainChanged(const QString&))); + // connect(&domainHandler, SIGNAL(resetting()), SLOT(resettingDomain())); + // connect(&domainHandler, SIGNAL(connectedToDomain(const QString&)), SLOT(updateWindowTitle())); + // connect(&domainHandler, SIGNAL(disconnectedFromDomain()), SLOT(updateWindowTitle())); + // connect(&domainHandler, SIGNAL(disconnectedFromDomain()), SLOT(clearDomainOctreeDetails())); + connect(&domainHandler, &DomainHandler::domainConnectionRefused, this, &ACClientApp::domainConnectionRefused); + + connect(nodeList.data(), &NodeList::nodeAdded, this, &ACClientApp::nodeAdded); + connect(nodeList.data(), &NodeList::nodeKilled, this, &ACClientApp::nodeKilled); + connect(nodeList.data(), &NodeList::nodeActivated, this, &ACClientApp::nodeActivated); + // connect(nodeList.data(), &NodeList::uuidChanged, getMyAvatar(), &MyAvatar::setSessionUUID); + // connect(nodeList.data(), &NodeList::uuidChanged, this, &ACClientApp::setSessionUUID); + // connect(nodeList.data(), &NodeList::packetVersionMismatch, this, &ACClientApp::notifyPacketVersionMismatch); + + // // you might think we could just do this in NodeList but we only want this connection for Interface + // connect(nodeList.data(), &NodeList::limitOfSilentDomainCheckInsReached, nodeList.data(), &NodeList::reset); + + // AccountManager _accountManager = new AccountManager(std::bind(&ACClientApp::getUserAgent, qApp)); + + // setState(lookUpStunServer); + + + nodeList->addSetOfNodeTypesToNodeInterestSet(NodeSet() << NodeType::AudioMixer << NodeType::AvatarMixer + << NodeType::EntityServer << NodeType::AssetServer << NodeType::MessagesMixer); + + + // // send the identity packet for our avatar each second to our avatar mixer + // connect(&identityPacketTimer, &QTimer::timeout, getMyAvatar(), &MyAvatar::sendIdentityPacket); + // identityPacketTimer.start(AVATAR_IDENTITY_PACKET_SEND_INTERVAL_MSECS); + + + // DependencyManager::get()->loadSettings(domainServerAddress); + + DependencyManager::get()->handleLookupString(domainServerAddress, false); + + QTimer* doTimer = new QTimer(this); + doTimer->setSingleShot(true); + connect(doTimer, &QTimer::timeout, this, &ACClientApp::timedOut); + doTimer->start(4000); +} + +ACClientApp::~ACClientApp() { +} + + +void ACClientApp::domainConnectionRefused(const QString& reasonMessage, int reasonCodeInt, const QString& extraInfo) { + qDebug() << "domainConnectionRefused"; +} + +void ACClientApp::domainChanged(const QString& domainHostname) { + if (_verbose) { + qDebug() << "domainChanged"; + } +} + +void ACClientApp::nodeAdded(SharedNodePointer node) { + if (_verbose) { + qDebug() << "node added: " << node->getType(); + } +} + +void ACClientApp::nodeActivated(SharedNodePointer node) { + if (node->getType() == NodeType::EntityServer) { + if (_verbose) { + qDebug() << "saw EntityServer"; + } + _sawEntityServer = true; + } + else if (node->getType() == NodeType::AudioMixer) { + if (_verbose) { + qDebug() << "saw AudioMixer"; + } + _sawAudioMixer = true; + } + else if (node->getType() == NodeType::AvatarMixer) { + if (_verbose) { + qDebug() << "saw AvatarMixer"; + } + _sawAvatarMixer = true; + } + else if (node->getType() == NodeType::AssetServer) { + if (_verbose) { + qDebug() << "saw AssetServer"; + } + _sawAssetServer = true; + } + else if (node->getType() == NodeType::MessagesMixer) { + if (_verbose) { + qDebug() << "saw MessagesMixer"; + } + _sawMessagesMixer = true; + } + + if (_sawEntityServer && _sawAudioMixer && _sawAvatarMixer && _sawAssetServer && _sawMessagesMixer) { + if (_verbose) { + qDebug() << "success"; + } + finish(0); + } +} + +void ACClientApp::nodeKilled(SharedNodePointer node) { + qDebug() << "nodeKilled"; +} + +void ACClientApp::timedOut() { + if (_verbose) { + qDebug() << "timed out: " << _sawEntityServer << _sawAudioMixer << + _sawAvatarMixer << _sawAssetServer << _sawMessagesMixer; + } + finish(1); +} + +void ACClientApp::finish(int exitCode) { + auto nodeList = DependencyManager::get(); + + // send the domain a disconnect packet, force stoppage of domain-server check-ins + nodeList->getDomainHandler().disconnect(); + nodeList->setIsShuttingDown(true); + + // tell the packet receiver we're shutting down, so it can drop packets + nodeList->getPacketReceiver().setShouldDropPackets(true); + + QThread* nodeThread = DependencyManager::get()->thread(); + // remove the NodeList from the DependencyManager + DependencyManager::destroy(); + // ask the node thread to quit and wait until it is done + nodeThread->quit(); + nodeThread->wait(); + + QCoreApplication::exit(exitCode); +} diff --git a/tools/ac-client/src/ACClientApp.h b/tools/ac-client/src/ACClientApp.h new file mode 100644 index 0000000000..36de592401 --- /dev/null +++ b/tools/ac-client/src/ACClientApp.h @@ -0,0 +1,55 @@ +// +// ACClientApp.h +// tools/ac-client/src +// +// Created by Seth Alves on 2016-10-5 +// Copyright 2016 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + + +#ifndef hifi_ACClientApp_h +#define hifi_ACClientApp_h + +#include +#include +#include +#include +#include +#include + + +class ACClientApp : public QCoreApplication { + Q_OBJECT +public: + ACClientApp(int argc, char* argv[]); + ~ACClientApp(); + + const int stunFailureExitStatus { 1 }; + const int iceFailureExitStatus { 2 }; + const int domainPingExitStatus { 3 }; + +private slots: + void domainConnectionRefused(const QString& reasonMessage, int reasonCodeInt, const QString& extraInfo); + void domainChanged(const QString& domainHostname); + void nodeAdded(SharedNodePointer node); + void nodeActivated(SharedNodePointer node); + void nodeKilled(SharedNodePointer node); + +private: + NodeList* _nodeList; + void timedOut(); + void finish(int exitCode); + bool _verbose; + QTimer* _pingDomainTimer { nullptr }; + + bool _sawEntityServer { false }; + bool _sawAudioMixer { false }; + bool _sawAvatarMixer { false }; + bool _sawAssetServer { false }; + bool _sawMessagesMixer { false }; +}; + +#endif //hifi_ACClientApp_h diff --git a/tools/ac-client/src/main.cpp b/tools/ac-client/src/main.cpp new file mode 100644 index 0000000000..918df6413f --- /dev/null +++ b/tools/ac-client/src/main.cpp @@ -0,0 +1,23 @@ +// +// main.cpp +// tools/ice-client/src +// +// Created by Seth Alves on 2016-10-5 +// Copyright 2016 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html + +#include +#include +#include +#include + +#include "ACClientApp.h" + +using namespace std; + +int main(int argc, char * argv[]) { + ACClientApp app(argc, argv); + return app.exec(); +} From 35755ddcb1f96d6ca433b98fbb081048484a60c0 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 5 Oct 2016 13:48:54 -0700 Subject: [PATCH 3/8] cleanups --- tools/ac-client/src/ACClientApp.cpp | 43 ----------------------------- 1 file changed, 43 deletions(-) diff --git a/tools/ac-client/src/ACClientApp.cpp b/tools/ac-client/src/ACClientApp.cpp index 3ea2322ffd..0d952e8cc1 100644 --- a/tools/ac-client/src/ACClientApp.cpp +++ b/tools/ac-client/src/ACClientApp.cpp @@ -68,31 +68,6 @@ ACClientApp::ACClientApp(int argc, char* argv[]) : const_cast(&shared())->setEnabled(QtWarningMsg, false); } - // QString domainServerAddress = "127.0.0.1"; - // if (parser.isSet(domainAddressOption)) { - // // parse the IP and port combination for this target - // QString hostnamePortString = parser.value(domainAddressOption); - - // QHostAddress address { hostnamePortString.left(hostnamePortString.indexOf(':')) }; - // quint16 port { (quint16) hostnamePortString.mid(hostnamePortString.indexOf(':') + 1).toUInt() }; - // if (port == 0) { - // port = DEFAULT_DOMAIN_SERVER_PORT; - // } - - // if (address.isNull()) { - // qCritical() << "Could not parse an IP address and port combination from" << hostnamePortString << "-" << - // "The parsed IP was" << address.toString() << "and the parsed port was" << port; - - // QMetaObject::invokeMethod(this, "quit", Qt::QueuedConnection); - // } else { - // _iceServerAddr = HifiSockAddr(address, port); - // } - - // if (_verbose) { - // qDebug() << "domain-server Address is" << domainServerAddress << "port is" << port; - // } - // } - QString domainServerAddress = "127.0.0.1:40103"; if (parser.isSet(domainAddressOption)) { domainServerAddress = parser.value(domainAddressOption); @@ -109,7 +84,6 @@ ACClientApp::ACClientApp(int argc, char* argv[]) : Setting::preInit(); DependencyManager::registerInheritance(); - // DependencyManager::registerInheritance(); Setting::init(); DependencyManager::set([&]{ return QString("Mozilla/5.0 (HighFidelityACClient)"); }); @@ -135,7 +109,6 @@ ACClientApp::ACClientApp(int argc, char* argv[]) : // put the NodeList and datagram processing on the node thread nodeList->moveToThread(nodeThread); - const DomainHandler& domainHandler = nodeList->getDomainHandler(); connect(&domainHandler, SIGNAL(hostnameChanged(const QString&)), SLOT(domainChanged(const QString&))); @@ -152,25 +125,9 @@ ACClientApp::ACClientApp(int argc, char* argv[]) : // connect(nodeList.data(), &NodeList::uuidChanged, this, &ACClientApp::setSessionUUID); // connect(nodeList.data(), &NodeList::packetVersionMismatch, this, &ACClientApp::notifyPacketVersionMismatch); - // // you might think we could just do this in NodeList but we only want this connection for Interface - // connect(nodeList.data(), &NodeList::limitOfSilentDomainCheckInsReached, nodeList.data(), &NodeList::reset); - - // AccountManager _accountManager = new AccountManager(std::bind(&ACClientApp::getUserAgent, qApp)); - - // setState(lookUpStunServer); - - nodeList->addSetOfNodeTypesToNodeInterestSet(NodeSet() << NodeType::AudioMixer << NodeType::AvatarMixer << NodeType::EntityServer << NodeType::AssetServer << NodeType::MessagesMixer); - - // // send the identity packet for our avatar each second to our avatar mixer - // connect(&identityPacketTimer, &QTimer::timeout, getMyAvatar(), &MyAvatar::sendIdentityPacket); - // identityPacketTimer.start(AVATAR_IDENTITY_PACKET_SEND_INTERVAL_MSECS); - - - // DependencyManager::get()->loadSettings(domainServerAddress); - DependencyManager::get()->handleLookupString(domainServerAddress, false); QTimer* doTimer = new QTimer(this); From 1dc52d3bf579d6d621fc9f3109427c5a566ffed2 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 5 Oct 2016 13:54:09 -0700 Subject: [PATCH 4/8] cleanups, fail if packet-version mismatch --- tools/ac-client/src/ACClientApp.cpp | 11 ++++++++--- tools/ac-client/src/ACClientApp.h | 6 +----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/tools/ac-client/src/ACClientApp.cpp b/tools/ac-client/src/ACClientApp.cpp index 0d952e8cc1..f174f50ab6 100644 --- a/tools/ac-client/src/ACClientApp.cpp +++ b/tools/ac-client/src/ACClientApp.cpp @@ -113,8 +113,6 @@ ACClientApp::ACClientApp(int argc, char* argv[]) : connect(&domainHandler, SIGNAL(hostnameChanged(const QString&)), SLOT(domainChanged(const QString&))); // connect(&domainHandler, SIGNAL(resetting()), SLOT(resettingDomain())); - // connect(&domainHandler, SIGNAL(connectedToDomain(const QString&)), SLOT(updateWindowTitle())); - // connect(&domainHandler, SIGNAL(disconnectedFromDomain()), SLOT(updateWindowTitle())); // connect(&domainHandler, SIGNAL(disconnectedFromDomain()), SLOT(clearDomainOctreeDetails())); connect(&domainHandler, &DomainHandler::domainConnectionRefused, this, &ACClientApp::domainConnectionRefused); @@ -123,7 +121,7 @@ ACClientApp::ACClientApp(int argc, char* argv[]) : connect(nodeList.data(), &NodeList::nodeActivated, this, &ACClientApp::nodeActivated); // connect(nodeList.data(), &NodeList::uuidChanged, getMyAvatar(), &MyAvatar::setSessionUUID); // connect(nodeList.data(), &NodeList::uuidChanged, this, &ACClientApp::setSessionUUID); - // connect(nodeList.data(), &NodeList::packetVersionMismatch, this, &ACClientApp::notifyPacketVersionMismatch); + connect(nodeList.data(), &NodeList::packetVersionMismatch, this, &ACClientApp::notifyPacketVersionMismatch); nodeList->addSetOfNodeTypesToNodeInterestSet(NodeSet() << NodeType::AudioMixer << NodeType::AvatarMixer << NodeType::EntityServer << NodeType::AssetServer << NodeType::MessagesMixer); @@ -208,6 +206,13 @@ void ACClientApp::timedOut() { finish(1); } +void ACClientApp::notifyPacketVersionMismatch() { + if (_verbose) { + qDebug() << "packet version mismatch"; + } + finish(1); +} + void ACClientApp::finish(int exitCode) { auto nodeList = DependencyManager::get(); diff --git a/tools/ac-client/src/ACClientApp.h b/tools/ac-client/src/ACClientApp.h index 36de592401..f6c726dfbc 100644 --- a/tools/ac-client/src/ACClientApp.h +++ b/tools/ac-client/src/ACClientApp.h @@ -27,23 +27,19 @@ public: ACClientApp(int argc, char* argv[]); ~ACClientApp(); - const int stunFailureExitStatus { 1 }; - const int iceFailureExitStatus { 2 }; - const int domainPingExitStatus { 3 }; - private slots: void domainConnectionRefused(const QString& reasonMessage, int reasonCodeInt, const QString& extraInfo); void domainChanged(const QString& domainHostname); void nodeAdded(SharedNodePointer node); void nodeActivated(SharedNodePointer node); void nodeKilled(SharedNodePointer node); + void notifyPacketVersionMismatch(); private: NodeList* _nodeList; void timedOut(); void finish(int exitCode); bool _verbose; - QTimer* _pingDomainTimer { nullptr }; bool _sawEntityServer { false }; bool _sawAudioMixer { false }; From 86a31903851c2ee9b82933aa6ba12d7ca124e54c Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 5 Oct 2016 14:45:32 -0700 Subject: [PATCH 5/8] on failure, print names of servers that didn't connect --- tools/ac-client/src/ACClientApp.cpp | 19 +++++++++++++++++++ tools/ac-client/src/ACClientApp.h | 1 + 2 files changed, 20 insertions(+) diff --git a/tools/ac-client/src/ACClientApp.cpp b/tools/ac-client/src/ACClientApp.cpp index f174f50ab6..df0f0c56ca 100644 --- a/tools/ac-client/src/ACClientApp.cpp +++ b/tools/ac-client/src/ACClientApp.cpp @@ -213,6 +213,24 @@ void ACClientApp::notifyPacketVersionMismatch() { finish(1); } +void ACClientApp::printFailedServers() { + if (!_sawEntityServer) { + qDebug() << "EntityServer"; + } + if (!_sawAudioMixer) { + qDebug() << "AudioMixer"; + } + if (!_sawAvatarMixer) { + qDebug() << "AvatarMixer"; + } + if (!_sawAssetServer) { + qDebug() << "AssetServer"; + } + if (!_sawMessagesMixer) { + qDebug() << "MessagesMixer"; + } +} + void ACClientApp::finish(int exitCode) { auto nodeList = DependencyManager::get(); @@ -230,5 +248,6 @@ void ACClientApp::finish(int exitCode) { nodeThread->quit(); nodeThread->wait(); + printFailedServers(); QCoreApplication::exit(exitCode); } diff --git a/tools/ac-client/src/ACClientApp.h b/tools/ac-client/src/ACClientApp.h index f6c726dfbc..29d571688e 100644 --- a/tools/ac-client/src/ACClientApp.h +++ b/tools/ac-client/src/ACClientApp.h @@ -38,6 +38,7 @@ private slots: private: NodeList* _nodeList; void timedOut(); + void printFailedServers(); void finish(int exitCode); bool _verbose; From 785d67b87a6377813d64b43c1946facac092c795 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 5 Oct 2016 15:25:45 -0700 Subject: [PATCH 6/8] remove redundant addHelpOption --- tools/ac-client/src/ACClientApp.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/ac-client/src/ACClientApp.cpp b/tools/ac-client/src/ACClientApp.cpp index df0f0c56ca..dad0a6d617 100644 --- a/tools/ac-client/src/ACClientApp.cpp +++ b/tools/ac-client/src/ACClientApp.cpp @@ -27,7 +27,6 @@ ACClientApp::ACClientApp(int argc, char* argv[]) : // parse command-line QCommandLineParser parser; parser.setApplicationDescription("High Fidelity AC client"); - parser.addHelpOption(); const QCommandLineOption helpOption = parser.addHelpOption(); From 0510411ac139fb963d6ad25900b11c88296c2b24 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 5 Oct 2016 16:19:39 -0700 Subject: [PATCH 7/8] fix timer use --- tools/ice-client/src/ICEClientApp.cpp | 42 +++++++++++++-------------- tools/ice-client/src/ICEClientApp.h | 6 ++-- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/tools/ice-client/src/ICEClientApp.cpp b/tools/ice-client/src/ICEClientApp.cpp index 992014ad7d..e0a08b7fcb 100644 --- a/tools/ice-client/src/ICEClientApp.cpp +++ b/tools/ice-client/src/ICEClientApp.cpp @@ -178,16 +178,9 @@ void ICEClientApp::doSomething() { qDebug() << "sending STUN request"; } _socket->writeDatagram(stunRequestPacket, sizeof(stunRequestPacket), _stunSockAddr); - _stunResponseTimerCanceled = false; - _stunResponseTimer.singleShot(stunResponseTimeoutMilliSeconds, this, [&] { - if (_stunResponseTimerCanceled) { - return; - } - if (_verbose) { - qDebug() << "timeout waiting for stun-server response"; - } - QCoreApplication::exit(stunFailureExitStatus); - }); + _stunResponseTimer.setSingleShot(true); + connect(&_iceResponseTimer, SIGNAL(timeout()), this, SLOT(stunResponseTimeout())); + _stunResponseTimer.start(stunResponseTimeoutMilliSeconds); setState(waitForStunResponse); } else { @@ -215,16 +208,9 @@ void ICEClientApp::doSomething() { } sendPacketToIceServer(PacketType::ICEServerQuery, _iceServerAddr, _sessionUUID, peerID); - _iceResponseTimerCanceled = false; - _iceResponseTimer.singleShot(iceResponseTimeoutMilliSeconds, this, [=] { - if (_iceResponseTimerCanceled) { - return; - } - if (_verbose) { - qDebug() << "timeout waiting for ice-server response"; - } - QCoreApplication::exit(iceFailureExitStatus); - }); + _iceResponseTimer.setSingleShot(true); + connect(&_iceResponseTimer, SIGNAL(timeout()), this, SLOT(iceResponseTimeout())); + _iceResponseTimer.start(iceResponseTimeoutMilliSeconds); } else if (_state == pause0) { setState(pause1); } else if (_state == pause1) { @@ -237,6 +223,20 @@ void ICEClientApp::doSomething() { } } +void ICEClientApp::iceResponseTimeout() { + if (_verbose) { + qDebug() << "timeout waiting for ice-server response"; + } + QCoreApplication::exit(iceFailureExitStatus); +} + +void ICEClientApp::stunResponseTimeout() { + if (_verbose) { + qDebug() << "timeout waiting for stun-server response"; + } + QCoreApplication::exit(stunFailureExitStatus); +} + void ICEClientApp::sendPacketToIceServer(PacketType packetType, const HifiSockAddr& iceServerSockAddr, const QUuid& clientID, const QUuid& peerID) { std::unique_ptr icePacket = NLPacket::create(packetType); @@ -298,7 +298,6 @@ void ICEClientApp::processSTUNResponse(std::unique_ptr packet) } _stunResponseTimer.stop(); - _stunResponseTimerCanceled = true; uint16_t newPublicPort; QHostAddress newPublicAddress; @@ -331,7 +330,6 @@ void ICEClientApp::processPacket(std::unique_ptr packet) { if (nlPacket->getType() == PacketType::ICEServerPeerInformation) { // cancel the timeout timer _iceResponseTimer.stop(); - _iceResponseTimerCanceled = true; QDataStream iceResponseStream(message->getMessage()); if (!_domainServerPeerSet) { diff --git a/tools/ice-client/src/ICEClientApp.h b/tools/ice-client/src/ICEClientApp.h index 3635bc07f4..de6b6abb14 100644 --- a/tools/ice-client/src/ICEClientApp.h +++ b/tools/ice-client/src/ICEClientApp.h @@ -33,6 +33,10 @@ public: const int stunResponseTimeoutMilliSeconds { 2000 }; const int iceResponseTimeoutMilliSeconds { 2000 }; +public slots: + void iceResponseTimeout(); + void stunResponseTimeout(); + private: enum State { lookUpStunServer, // 0 @@ -83,9 +87,7 @@ private: int _state { 0 }; QTimer _stunResponseTimer; - bool _stunResponseTimerCanceled { false }; QTimer _iceResponseTimer; - bool _iceResponseTimerCanceled { false }; int _domainPingCount { 0 }; }; From f338e38bcf7eaeeae290ae721aa5d49275163c42 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 5 Oct 2016 16:25:00 -0700 Subject: [PATCH 8/8] oops --- tools/ice-client/src/ICEClientApp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/ice-client/src/ICEClientApp.cpp b/tools/ice-client/src/ICEClientApp.cpp index e0a08b7fcb..f9e7a76142 100644 --- a/tools/ice-client/src/ICEClientApp.cpp +++ b/tools/ice-client/src/ICEClientApp.cpp @@ -179,7 +179,7 @@ void ICEClientApp::doSomething() { } _socket->writeDatagram(stunRequestPacket, sizeof(stunRequestPacket), _stunSockAddr); _stunResponseTimer.setSingleShot(true); - connect(&_iceResponseTimer, SIGNAL(timeout()), this, SLOT(stunResponseTimeout())); + connect(&_stunResponseTimer, SIGNAL(timeout()), this, SLOT(stunResponseTimeout())); _stunResponseTimer.start(stunResponseTimeoutMilliSeconds); setState(waitForStunResponse);