diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index 4b5cd3f0e3..e5bf027a00 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -119,7 +119,7 @@ LimitedNodeList::LimitedNodeList(int socketListenPort, int dtlsListenPort) : _nodeSocket.setConnectionCreationFilterOperator(std::bind(&LimitedNodeList::sockAddrBelongsToNode, this, _1)); // handle when a socket connection has its receiver side reset - might need to emit clientConnectionToNodeReset - connect(&_nodeSocket, &udt::Socket::clientHandshakeComplete, this, &LimitedNodeList::clientConnectionToSockAddrReset); + connect(&_nodeSocket, &udt::Socket::clientHandshakeRequestComplete, this, &LimitedNodeList::clientConnectionToSockAddrReset); _packetStatTimer.start(); diff --git a/libraries/networking/src/udt/Connection.cpp b/libraries/networking/src/udt/Connection.cpp index e509cc15d6..1a04ea0e7a 100644 --- a/libraries/networking/src/udt/Connection.cpp +++ b/libraries/networking/src/udt/Connection.cpp @@ -434,6 +434,8 @@ bool Connection::processReceivedSequenceNumber(SequenceNumber sequenceNumber, in auto handshakeRequestPacket = ControlPacket::create(ControlPacket::HandshakeRequest, 0); _parentSocket->writeBasePacket(*handshakeRequestPacket, _destination); + _didRequestHandshake = true; + #ifdef UDT_CONNECTION_DEBUG qCDebug(networking) << "Received packet before receiving handshake, sending HandshakeRequest"; #endif @@ -790,7 +792,10 @@ void Connection::processHandshake(ControlPacketPointer controlPacket) { // indicate that handshake has been received _hasReceivedHandshake = true; - emit receiverHandshakeComplete(_destination); + if (_didRequestHandshake) { + emit receiverHandshakeRequestComplete(_destination); + _didRequestHandshake = false; + } } void Connection::processHandshakeACK(ControlPacketPointer controlPacket) { diff --git a/libraries/networking/src/udt/Connection.h b/libraries/networking/src/udt/Connection.h index 19693c8b31..c35db2bf27 100644 --- a/libraries/networking/src/udt/Connection.h +++ b/libraries/networking/src/udt/Connection.h @@ -82,7 +82,7 @@ public: signals: void packetSent(); void connectionInactive(const HifiSockAddr& sockAddr); - void receiverHandshakeComplete(const HifiSockAddr& sockAddr); + void receiverHandshakeRequestComplete(const HifiSockAddr& sockAddr); private slots: void recordSentPackets(int payload, int total); @@ -130,6 +130,7 @@ private: bool _hasReceivedHandshake { false }; // flag for receipt of handshake from server bool _hasReceivedHandshakeACK { false }; // flag for receipt of handshake ACK from client + bool _didRequestHandshake { false }; // flag for request of handshake from server p_high_resolution_clock::time_point _connectionStart = p_high_resolution_clock::now(); // holds the time_point for creation of this connection p_high_resolution_clock::time_point _lastReceiveTime; // holds the last time we received anything from sender diff --git a/libraries/networking/src/udt/Socket.cpp b/libraries/networking/src/udt/Socket.cpp index 3edd160377..69975e390e 100644 --- a/libraries/networking/src/udt/Socket.cpp +++ b/libraries/networking/src/udt/Socket.cpp @@ -237,7 +237,8 @@ Connection* Socket::findOrCreateConnection(const HifiSockAddr& sockAddr) { QObject::connect(connection.get(), &Connection::connectionInactive, this, &Socket::cleanupConnection); // allow higher-level classes to find out when connections have completed a handshake - QObject::connect(connection.get(), &Connection::receiverHandshakeComplete, this, &Socket::clientHandshakeComplete); + QObject::connect(connection.get(), &Connection::receiverHandshakeRequestComplete, + this, &Socket::clientHandshakeRequestComplete); #ifdef UDT_CONNECTION_DEBUG qCDebug(networking) << "Creating new connection to" << sockAddr; diff --git a/libraries/networking/src/udt/Socket.h b/libraries/networking/src/udt/Socket.h index 7baff03481..f6f94cd2de 100644 --- a/libraries/networking/src/udt/Socket.h +++ b/libraries/networking/src/udt/Socket.h @@ -84,7 +84,7 @@ public: StatsVector sampleStatsForAllConnections(); signals: - void clientHandshakeComplete(const HifiSockAddr& sockAddr); + void clientHandshakeRequestComplete(const HifiSockAddr& sockAddr); public slots: void cleanupConnection(HifiSockAddr sockAddr);