only emit client connection reset on requested handshake

This commit is contained in:
Stephen Birarda 2016-10-14 13:17:45 -07:00
parent eb77258c55
commit ccbfdf7bb9
5 changed files with 12 additions and 5 deletions

View file

@ -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();

View file

@ -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) {

View file

@ -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

View file

@ -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;

View file

@ -84,7 +84,7 @@ public:
StatsVector sampleStatsForAllConnections();
signals:
void clientHandshakeComplete(const HifiSockAddr& sockAddr);
void clientHandshakeRequestComplete(const HifiSockAddr& sockAddr);
public slots:
void cleanupConnection(HifiSockAddr sockAddr);