diff --git a/ice-server/src/IceServer.cpp b/ice-server/src/IceServer.cpp index 7bd8306e9b..128c2b27b0 100644 --- a/ice-server/src/IceServer.cpp +++ b/ice-server/src/IceServer.cpp @@ -69,8 +69,6 @@ bool IceServer::packetVersionMatch(const udt::Packet& packet) { void IceServer::processPacket(std::unique_ptr packet) { - _lastPacketTimestamp = QDateTime::currentMSecsSinceEpoch(); - auto nlPacket = NLPacket::fromBase(std::move(packet)); // make sure that this packet at least looks like something we can read @@ -282,6 +280,8 @@ void IceServer::sendPeerInformationPacket(const NetworkPeer& peer, const HifiSoc void IceServer::clearInactivePeers() { NetworkPeerHash::iterator peerItem = _activePeers.begin(); + _lastInactiveCheckTimestamp = QDateTime::currentMSecsSinceEpoch(); + while (peerItem != _activePeers.end()) { SharedNetworkPeer peer = peerItem.value(); @@ -310,8 +310,8 @@ bool IceServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url, b const quint64 MAX_PACKET_GAP_MS_FOR_STUCK_SOCKET = 10 * 1000; - int statusNumber = (QDateTime::currentMSecsSinceEpoch() - _lastPacketTimestamp > MAX_PACKET_GAP_MS_FOR_STUCK_SOCKET) - ? 1 : 0; + auto sinceLastInactiveCheck = QDateTime::currentMSecsSinceEpoch() - _lastInactiveCheckTimestamp; + int statusNumber = (sinceLastInactiveCheck > MAX_PACKET_GAP_MS_FOR_STUCK_SOCKET) ? 1 : 0; connection->respond(HTTPConnection::StatusCode200, QByteArray::number(statusNumber)); diff --git a/ice-server/src/IceServer.h b/ice-server/src/IceServer.h index 6cc33fd8fc..7d1d05324c 100644 --- a/ice-server/src/IceServer.h +++ b/ice-server/src/IceServer.h @@ -58,7 +58,7 @@ private: using DomainPublicKeyHash = std::unordered_map; DomainPublicKeyHash _domainPublicKeys; - quint64 _lastPacketTimestamp; + quint64 _lastInactiveCheckTimestamp; }; #endif // hifi_IceServer_h