reset silent check in packet check on domain connection reset

This commit is contained in:
Stephen Birarda 2018-01-17 11:55:46 -08:00
parent 28c9cd15a4
commit e16a3859c2
5 changed files with 26 additions and 19 deletions

View file

@ -1046,7 +1046,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
connect(nodeList.data(), &NodeList::packetVersionMismatch, this, &Application::notifyPacketVersionMismatch); connect(nodeList.data(), &NodeList::packetVersionMismatch, this, &Application::notifyPacketVersionMismatch);
// you might think we could just do this in NodeList but we only want this connection for Interface // 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); connect(&nodeList->getDomainHandler(), &DomainHandler::limitOfSilentDomainCheckInsReached,
nodeList.data(), &NodeList::reset);
auto dialogsManager = DependencyManager::get<DialogsManager>(); auto dialogsManager = DependencyManager::get<DialogsManager>();
connect(accountManager.data(), &AccountManager::authRequired, dialogsManager.data(), &DialogsManager::showLoginDialog); connect(accountManager.data(), &AccountManager::authRequired, dialogsManager.data(), &DialogsManager::showLoginDialog);

View file

@ -98,6 +98,7 @@ void DomainHandler::softReset() {
clearSettings(); clearSettings();
_connectionDenialsSinceKeypairRegen = 0; _connectionDenialsSinceKeypairRegen = 0;
_checkInPacketsSinceLastReply = 0;
// cancel the failure timeout for any pending requests for settings // cancel the failure timeout for any pending requests for settings
QMetaObject::invokeMethod(&_settingsTimer, "stop"); QMetaObject::invokeMethod(&_settingsTimer, "stop");
@ -426,3 +427,14 @@ void DomainHandler::processDomainServerConnectionDeniedPacket(QSharedPointer<Rec
} }
} }
} }
void DomainHandler::sentCheckInPacket() {
++_checkInPacketsSinceLastReply;
if (_checkInPacketsSinceLastReply >= MAX_SILENT_DOMAIN_SERVER_CHECK_INS) {
// we haven't heard back from DS in MAX_SILENT_DOMAIN_SERVER_CHECK_INS
// so emit our signal that says that
qCDebug(networking) << "Limit of silent domain checkins reached";
emit limitOfSilentDomainCheckInsReached();
}
}

View file

@ -31,6 +31,8 @@ const unsigned short DEFAULT_DOMAIN_SERVER_DTLS_PORT = 40103;
const quint16 DOMAIN_SERVER_HTTP_PORT = 40100; const quint16 DOMAIN_SERVER_HTTP_PORT = 40100;
const quint16 DOMAIN_SERVER_HTTPS_PORT = 40101; const quint16 DOMAIN_SERVER_HTTPS_PORT = 40101;
const int MAX_SILENT_DOMAIN_SERVER_CHECK_INS = 5;
class DomainHandler : public QObject { class DomainHandler : public QObject {
Q_OBJECT Q_OBJECT
public: public:
@ -84,6 +86,10 @@ public:
void softReset(); void softReset();
int getCheckInPacketsSinceLastReply() const { return _checkInPacketsSinceLastReply; }
void sentCheckInPacket();
void domainListReceived() { _checkInPacketsSinceLastReply = 0; }
/**jsdoc /**jsdoc
* <p>The reasons that you may be refused connection to a domain are defined by numeric values:</p> * <p>The reasons that you may be refused connection to a domain are defined by numeric values:</p>
* <table> * <table>
@ -165,6 +171,8 @@ signals:
void domainConnectionRefused(QString reasonMessage, int reason, const QString& extraInfo); void domainConnectionRefused(QString reasonMessage, int reason, const QString& extraInfo);
void limitOfSilentDomainCheckInsReached();
private: private:
bool reasonSuggestsLogin(ConnectionRefusedReason reasonCode); bool reasonSuggestsLogin(ConnectionRefusedReason reasonCode);
void sendDisconnectPacket(); void sendDisconnectPacket();
@ -187,6 +195,7 @@ private:
QSet<QString> _domainConnectionRefusals; QSet<QString> _domainConnectionRefusals;
bool _hasCheckedForAccessToken { false }; bool _hasCheckedForAccessToken { false };
int _connectionDenialsSinceKeypairRegen { 0 }; int _connectionDenialsSinceKeypairRegen { 0 };
int _checkInPacketsSinceLastReply { 0 };
QTimer _apiRefreshTimer; QTimer _apiRefreshTimer;
}; };

View file

@ -44,7 +44,6 @@ NodeList::NodeList(char newOwnerType, int socketListenPort, int dtlsListenPort)
_ownerType(newOwnerType), _ownerType(newOwnerType),
_nodeTypesOfInterest(), _nodeTypesOfInterest(),
_domainHandler(this), _domainHandler(this),
_numNoReplyDomainCheckIns(0),
_assignmentServerSocket(), _assignmentServerSocket(),
_keepAlivePingTimer(this) _keepAlivePingTimer(this)
{ {
@ -239,8 +238,6 @@ void NodeList::reset() {
LimitedNodeList::reset(); LimitedNodeList::reset();
_numNoReplyDomainCheckIns = 0;
// lock and clear our set of ignored IDs // lock and clear our set of ignored IDs
_ignoredSetLock.lockForWrite(); _ignoredSetLock.lockForWrite();
_ignoredNodeIDs.clear(); _ignoredNodeIDs.clear();
@ -410,15 +407,8 @@ void NodeList::sendDomainServerCheckIn() {
sendPacket(std::move(domainPacket), _domainHandler.getSockAddr()); sendPacket(std::move(domainPacket), _domainHandler.getSockAddr());
if (_numNoReplyDomainCheckIns >= MAX_SILENT_DOMAIN_SERVER_CHECK_INS) { // let the domain handler know we sent another check in or connect packet
// we haven't heard back from DS in MAX_SILENT_DOMAIN_SERVER_CHECK_INS _domainHandler.sentCheckInPacket();
// so emit our signal that says that
qCDebug(networking) << "Limit of silent domain checkins reached";
emit limitOfSilentDomainCheckInsReached();
}
// increment the count of un-replied check-ins
_numNoReplyDomainCheckIns++;
} }
} }
@ -585,7 +575,7 @@ void NodeList::processDomainServerList(QSharedPointer<ReceivedMessage> message)
} }
// this is a packet from the domain server, reset the count of un-replied check-ins // this is a packet from the domain server, reset the count of un-replied check-ins
_numNoReplyDomainCheckIns = 0; _domainHandler.domainListReceived();
// emit our signal so listeners know we just heard from the DS // emit our signal so listeners know we just heard from the DS
emit receivedDomainServerList(); emit receivedDomainServerList();

View file

@ -38,8 +38,6 @@
const quint64 DOMAIN_SERVER_CHECK_IN_MSECS = 1 * 1000; const quint64 DOMAIN_SERVER_CHECK_IN_MSECS = 1 * 1000;
const int MAX_SILENT_DOMAIN_SERVER_CHECK_INS = 5;
using PacketOrPacketList = std::pair<std::unique_ptr<NLPacket>, std::unique_ptr<NLPacketList>>; using PacketOrPacketList = std::pair<std::unique_ptr<NLPacket>, std::unique_ptr<NLPacketList>>;
using NodePacketOrPacketListPair = std::pair<SharedNodePointer, PacketOrPacketList>; using NodePacketOrPacketListPair = std::pair<SharedNodePointer, PacketOrPacketList>;
@ -62,7 +60,6 @@ public:
Q_INVOKABLE qint64 sendStats(QJsonObject statsObject, HifiSockAddr destination); Q_INVOKABLE qint64 sendStats(QJsonObject statsObject, HifiSockAddr destination);
Q_INVOKABLE qint64 sendStatsToDomainServer(QJsonObject statsObject); Q_INVOKABLE qint64 sendStatsToDomainServer(QJsonObject statsObject);
int getNumNoReplyDomainCheckIns() const { return _numNoReplyDomainCheckIns; }
DomainHandler& getDomainHandler() { return _domainHandler; } DomainHandler& getDomainHandler() { return _domainHandler; }
const NodeSet& getNodeInterestSet() const { return _nodeTypesOfInterest; } const NodeSet& getNodeInterestSet() const { return _nodeTypesOfInterest; }
@ -119,7 +116,6 @@ public slots:
#endif #endif
signals: signals:
void limitOfSilentDomainCheckInsReached();
void receivedDomainServerList(); void receivedDomainServerList();
void ignoredNode(const QUuid& nodeID, bool enabled); void ignoredNode(const QUuid& nodeID, bool enabled);
void ignoreRadiusEnabledChanged(bool isIgnored); void ignoreRadiusEnabledChanged(bool isIgnored);
@ -161,7 +157,6 @@ private:
std::atomic<NodeType_t> _ownerType; std::atomic<NodeType_t> _ownerType;
NodeSet _nodeTypesOfInterest; NodeSet _nodeTypesOfInterest;
DomainHandler _domainHandler; DomainHandler _domainHandler;
int _numNoReplyDomainCheckIns;
HifiSockAddr _assignmentServerSocket; HifiSockAddr _assignmentServerSocket;
bool _isShuttingDown { false }; bool _isShuttingDown { false };
QTimer _keepAlivePingTimer; QTimer _keepAlivePingTimer;