mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 05:58:35 +02:00
expire the connection if it is 16 timeouts since data
This commit is contained in:
parent
d6310da8c8
commit
abffc0317b
2 changed files with 21 additions and 1 deletions
|
@ -138,6 +138,21 @@ void Connection::queueReceivedMessagePacket(std::unique_ptr<Packet> packet) {
|
||||||
|
|
||||||
void Connection::sync() {
|
void Connection::sync() {
|
||||||
if (_hasReceivedFirstPacket) {
|
if (_hasReceivedFirstPacket) {
|
||||||
|
|
||||||
|
// check if it's time for us to consider this connection inactive
|
||||||
|
// we are inactive if it has been 16 * the estimated timeout since our last receive
|
||||||
|
static const int NUM_TIMEOUTS_FOR_EXPIRY = 16;
|
||||||
|
|
||||||
|
auto sinceLastReceive = duration_cast<microseconds>(high_resolution_clock::now() - _lastReceiveTime);
|
||||||
|
|
||||||
|
if (sinceLastReceive.count() >= NUM_TIMEOUTS_FOR_EXPIRY * estimatedTimeout()) {
|
||||||
|
// connection inactive - emit a signal so we will be cleaned up
|
||||||
|
emit connectionInactive(_destination);
|
||||||
|
|
||||||
|
// return to abort before regular processing
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// reset the number of light ACKs or non SYN ACKs during this sync interval
|
// reset the number of light ACKs or non SYN ACKs during this sync interval
|
||||||
_lightACKsDuringSYN = 1;
|
_lightACKsDuringSYN = 1;
|
||||||
_acksDuringSYN = 1;
|
_acksDuringSYN = 1;
|
||||||
|
@ -347,6 +362,9 @@ bool Connection::processReceivedSequenceNumber(SequenceNumber sequenceNumber, in
|
||||||
|
|
||||||
_hasReceivedFirstPacket = true;
|
_hasReceivedFirstPacket = true;
|
||||||
|
|
||||||
|
// mark our last receive time as now (to push the potential expiry farther)
|
||||||
|
_lastReceiveTime = high_resolution_clock::now();
|
||||||
|
|
||||||
// check if this is a packet pair we should estimate bandwidth from, or just a regular packet
|
// check if this is a packet pair we should estimate bandwidth from, or just a regular packet
|
||||||
if (((uint32_t) sequenceNumber & 0xF) == 0) {
|
if (((uint32_t) sequenceNumber & 0xF) == 0) {
|
||||||
_receiveWindow.onProbePair1Arrival();
|
_receiveWindow.onProbePair1Arrival();
|
||||||
|
|
|
@ -73,7 +73,7 @@ public:
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void packetSent();
|
void packetSent();
|
||||||
void connectionInactive(HifiSockAddr sockAdrr);
|
void connectionInactive(const HifiSockAddr& sockAddr);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void recordSentPackets(int payload, int total);
|
void recordSentPackets(int payload, int total);
|
||||||
|
@ -118,6 +118,8 @@ private:
|
||||||
bool _hasReceivedHandshake { false }; // flag for receipt of handshake from server
|
bool _hasReceivedHandshake { false }; // flag for receipt of handshake from server
|
||||||
bool _hasReceivedHandshakeACK { false }; // flag for receipt of handshake ACK from client
|
bool _hasReceivedHandshakeACK { false }; // flag for receipt of handshake ACK from client
|
||||||
|
|
||||||
|
std::chrono::high_resolution_clock::time_point _lastReceiveTime; // holds the last time we received anything from sender
|
||||||
|
|
||||||
LossList _lossList; // List of all missing packets
|
LossList _lossList; // List of all missing packets
|
||||||
SequenceNumber _lastReceivedSequenceNumber; // The largest sequence number received from the peer
|
SequenceNumber _lastReceivedSequenceNumber; // The largest sequence number received from the peer
|
||||||
SequenceNumber _lastReceivedACK; // The last ACK received
|
SequenceNumber _lastReceivedACK; // The last ACK received
|
||||||
|
|
Loading…
Reference in a new issue