Don't move Connection class to changed address until it's used

This commit is contained in:
Simon Walton 2019-09-24 16:39:59 -07:00
parent b491d00c00
commit 4f11e46b5e
4 changed files with 11 additions and 10 deletions

View file

@ -38,7 +38,7 @@ MixerAvatar::MixerAvatar() {
_pendingEvent = false; _pendingEvent = false;
_verifyState = verificationFailed; _verifyState = verificationFailed;
_needsIdentityUpdate = true; _needsIdentityUpdate = true;
qCDebug(avatars) << "Dynamic verification TIMED-OUT for " << getDisplayName() << getSessionUUID(); qCDebug(avatars) << "Dynamic verification TIMED-OUT for" << getDisplayName() << getSessionUUID();
} else { } else {
qCDebug(avatars) << "Ignoring timeout of avatar challenge"; qCDebug(avatars) << "Ignoring timeout of avatar challenge";
} }
@ -287,7 +287,7 @@ void MixerAvatar::processCertifyEvents() {
<< ":" << _dynamicMarketResponse; << ":" << _dynamicMarketResponse;
} }
} else { } else {
qCDebug(avatars) << "Get owner status failed for " << getDisplayName() << _marketplaceIdFromURL << qCDebug(avatars) << "Get owner status failed for" << getDisplayName() << _marketplaceIdFromURL <<
"message:" << responseJson["message"].toString(); "message:" << responseJson["message"].toString();
_verifyState = error; _verifyState = error;
} }
@ -356,7 +356,7 @@ void MixerAvatar::processChallengeResponse(ReceivedMessage& response) {
_verifyState = challengeResult ? verificationSucceeded : verificationFailed; _verifyState = challengeResult ? verificationSucceeded : verificationFailed;
_needsIdentityUpdate = true; _needsIdentityUpdate = true;
if (_verifyState == verificationFailed) { if (_verifyState == verificationFailed) {
qCDebug(avatars) << "Dynamic verification FAILED for " << getDisplayName() << getSessionUUID(); qCDebug(avatars) << "Dynamic verification FAILED for" << getDisplayName() << getSessionUUID();
} else { } else {
qCDebug(avatars) << "Dynamic verification SUCCEEDED for" << getDisplayName() << getSessionUUID(); qCDebug(avatars) << "Dynamic verification SUCCEEDED for" << getDisplayName() << getSessionUUID();
} }

View file

@ -269,7 +269,7 @@ bool Connection::processReceivedSequenceNumber(SequenceNumber sequenceNumber, in
bool wasDuplicate = false; bool wasDuplicate = false;
if (sequenceNumber > _lastReceivedSequenceNumber) { if (sequenceNumber > _lastReceivedSequenceNumber) {
// Update largest recieved sequence number // Update largest received sequence number
_lastReceivedSequenceNumber = sequenceNumber; _lastReceivedSequenceNumber = sequenceNumber;
} else { } else {
// Otherwise, it could be a resend, try and remove it from the loss list // Otherwise, it could be a resend, try and remove it from the loss list
@ -312,9 +312,7 @@ void Connection::processControl(ControlPacketPointer controlPacket) {
// We're already in a state where we've received a handshake ack, so we are likely in a state // We're already in a state where we've received a handshake ack, so we are likely in a state
// where the other end expired our connection. Let's reset. // where the other end expired our connection. Let's reset.
#ifdef UDT_CONNECTION_DEBUG qCDebug(networking) << "Got HandshakeRequest from" << _destination << "while active, stopping SendQueue";
qCDebug(networking) << "Got HandshakeRequest from" << _destination << ", stopping SendQueue";
#endif
_hasReceivedHandshakeACK = false; _hasReceivedHandshakeACK = false;
stopSendQueue(); stopSendQueue();
} }
@ -333,7 +331,7 @@ void Connection::processACK(ControlPacketPointer controlPacket) {
// validate that this isn't a BS ACK // validate that this isn't a BS ACK
if (ack > getSendQueue().getCurrentSequenceNumber()) { if (ack > getSendQueue().getCurrentSequenceNumber()) {
// in UDT they specifically break the connection here - do we want to do anything? // in UDT they specifically break the connection here - do we want to do anything?
Q_ASSERT_X(false, "Connection::processACK", "ACK recieved higher than largest sent sequence number"); Q_ASSERT_X(false, "Connection::processACK", "ACK received higher than largest sent sequence number");
return; return;
} }

View file

@ -73,6 +73,7 @@ public:
void setMaxBandwidth(int maxBandwidth); void setMaxBandwidth(int maxBandwidth);
void sendHandshakeRequest(); void sendHandshakeRequest();
bool hasReceivedHandshake() const { return _hasReceivedHandshake; }
void recordSentUnreliablePackets(int wireSize, int payloadSize); void recordSentUnreliablePackets(int wireSize, int payloadSize);
void recordReceivedUnreliablePackets(int wireSize, int payloadSize); void recordReceivedUnreliablePackets(int wireSize, int payloadSize);

View file

@ -261,7 +261,7 @@ Connection* Socket::findOrCreateConnection(const HifiSockAddr& sockAddr, bool fi
// we did not have a matching connection, time to see if we should make one // we did not have a matching connection, time to see if we should make one
if (filterCreate && _connectionCreationFilterOperator && !_connectionCreationFilterOperator(sockAddr)) { if (filterCreate && _connectionCreationFilterOperator && !_connectionCreationFilterOperator(sockAddr)) {
// the connection creation filter did not allow us to create a new connection // the connection creation filter did not allow us to create a new connectionclientHandshakeRequestComplete
#ifdef UDT_CONNECTION_DEBUG #ifdef UDT_CONNECTION_DEBUG
qCDebug(networking) << "Socket::findOrCreateConnection refusing to create Connection class for" << sockAddr qCDebug(networking) << "Socket::findOrCreateConnection refusing to create Connection class for" << sockAddr
<< "due to connection creation filter"; << "due to connection creation filter";
@ -548,12 +548,14 @@ void Socket::handleRemoteAddressChange(HifiSockAddr previousAddress, HifiSockAdd
Lock connectionsLock(_connectionsHashMutex); Lock connectionsLock(_connectionsHashMutex);
const auto connectionIter = _connectionsHash.find(previousAddress); const auto connectionIter = _connectionsHash.find(previousAddress);
if (connectionIter != _connectionsHash.end()) { // Don't move classes that are unused so far.
if (connectionIter != _connectionsHash.end() && connectionIter->second->hasReceivedHandshake()) {
auto connection = move(connectionIter->second); auto connection = move(connectionIter->second);
_connectionsHash.erase(connectionIter); _connectionsHash.erase(connectionIter);
connection->setDestinationAddress(currentAddress); connection->setDestinationAddress(currentAddress);
_connectionsHash[currentAddress] = move(connection); _connectionsHash[currentAddress] = move(connection);
connectionsLock.unlock(); connectionsLock.unlock();
qCDebug(networking) << "Moved Connection class from" << previousAddress << "to" << currentAddress;
Lock sequenceNumbersLock(_unreliableSequenceNumbersMutex); Lock sequenceNumbersLock(_unreliableSequenceNumbersMutex);
const auto sequenceNumbersIter = _unreliableSequenceNumbers.find(previousAddress); const auto sequenceNumbersIter = _unreliableSequenceNumbers.find(previousAddress);