mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 10:37:35 +02:00
use time since last packet as short-term status check
This commit is contained in:
parent
3e4b4a0fc7
commit
cffeece08e
2 changed files with 13 additions and 2 deletions
|
@ -68,6 +68,8 @@ bool IceServer::packetVersionMatch(const udt::Packet& packet) {
|
||||||
|
|
||||||
void IceServer::processPacket(std::unique_ptr<udt::Packet> packet) {
|
void IceServer::processPacket(std::unique_ptr<udt::Packet> packet) {
|
||||||
|
|
||||||
|
_lastPacketTimestamp = QDateTime::currentMSecsSinceEpoch();
|
||||||
|
|
||||||
auto nlPacket = NLPacket::fromBase(std::move(packet));
|
auto nlPacket = NLPacket::fromBase(std::move(packet));
|
||||||
|
|
||||||
// make sure that this packet at least looks like something we can read
|
// make sure that this packet at least looks like something we can read
|
||||||
|
@ -303,7 +305,14 @@ bool IceServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url, b
|
||||||
|
|
||||||
if (connection->requestOperation() == QNetworkAccessManager::GetOperation) {
|
if (connection->requestOperation() == QNetworkAccessManager::GetOperation) {
|
||||||
if (url.path() == "/status") {
|
if (url.path() == "/status") {
|
||||||
connection->respond(HTTPConnection::StatusCode200, QByteArray::number(_activePeers.size()));
|
// figure out if we respond with 0 (we're good) or 1 (we think we're in trouble)
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
connection->respond(HTTPConnection::StatusCode200, QByteArray::number(statusNumber));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -57,6 +57,8 @@ private:
|
||||||
using RSAUniquePtr = std::unique_ptr<RSA, std::function<void(RSA*)>>;
|
using RSAUniquePtr = std::unique_ptr<RSA, std::function<void(RSA*)>>;
|
||||||
using DomainPublicKeyHash = std::unordered_map<QUuid, RSAUniquePtr>;
|
using DomainPublicKeyHash = std::unordered_map<QUuid, RSAUniquePtr>;
|
||||||
DomainPublicKeyHash _domainPublicKeys;
|
DomainPublicKeyHash _domainPublicKeys;
|
||||||
|
|
||||||
|
quint64 _lastPacketTimestamp;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_IceServer_h
|
#endif // hifi_IceServer_h
|
||||||
|
|
Loading…
Reference in a new issue