Use NULL_LOCAL_ID in more places, as requested by review

This commit is contained in:
Simon Walton 2018-04-18 11:53:47 -07:00
parent 2ba64e1115
commit 01c39d4310
8 changed files with 12 additions and 14 deletions

View file

@ -123,7 +123,7 @@ void AudioMixer::queueReplicatedAudioPacket(QSharedPointer<ReceivedMessage> mess
auto replicatedNode = nodeList->addOrUpdateNode(nodeID, NodeType::Agent,
message->getSenderSockAddr(), message->getSenderSockAddr(),
0, true, true);
Node::NULL_LOCAL_ID, true, true);
replicatedNode->setLastHeardMicrostamp(usecTimestampNow());
// construct a "fake" audio received message from the byte array and packet list information

View file

@ -126,10 +126,7 @@ private:
// Local ID management.
void initLocalIDManagement();
struct UuidHash {
size_t operator()(const QUuid& uuid) const { return qHash(uuid); }
};
using UUIDToLocalID = std::unordered_map<QUuid, Node::LocalID, UuidHash> ;
using UUIDToLocalID = std::unordered_map<QUuid, Node::LocalID> ;
using LocalIDs = std::unordered_set<Node::LocalID>;
LocalIDs _localIDs;
UUIDToLocalID _uuidToLocalID;

View file

@ -2905,7 +2905,7 @@ void DomainServer::updateReplicationNodes(ReplicationServerDirection direction)
// manually add the replication node to our node list
auto node = nodeList->addOrUpdateNode(QUuid::createUuid(), replicationServer.nodeType,
replicationServer.sockAddr, replicationServer.sockAddr,
0, false, direction == Upstream);
Node::NULL_LOCAL_ID, false, direction == Upstream);
node->setIsForcedNeverSilent(true);
qDebug() << "Adding" << (direction == Upstream ? "upstream" : "downstream")

View file

@ -306,7 +306,7 @@ bool LimitedNodeList::packetSourceAndHashMatchAndTrackBandwidth(const udt::Packe
return true;
}
} else {
NLPacket::LocalID sourceLocalID = 0;
NLPacket::LocalID sourceLocalID = Node::NULL_LOCAL_ID;
// check if we were passed a sourceNode hint or if we need to look it up
if (!sourceNode) {
// figure out which node this is from

View file

@ -128,7 +128,7 @@ public:
virtual bool isDomainServer() const { return true; }
virtual QUuid getDomainUUID() const { assert(false); return QUuid(); }
virtual Node::LocalID getDomainLocalID() const { assert(false); return 0; }
virtual Node::LocalID getDomainLocalID() const { assert(false); return Node::NULL_LOCAL_ID; }
virtual HifiSockAddr getDomainSockAddr() const { assert(false); return HifiSockAddr(); }
// use sendUnreliablePacket to send an unrelaible packet (that you do not need to move)
@ -162,8 +162,8 @@ public:
SharedNodePointer addOrUpdateNode(const QUuid& uuid, NodeType_t nodeType,
const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket,
Node::LocalID localID = 0, bool isReplicated = false, bool isUpstream = false,
const QUuid& connectionSecret = QUuid(),
Node::LocalID localID = Node::NULL_LOCAL_ID, bool isReplicated = false,
bool isUpstream = false, const QUuid& connectionSecret = QUuid(),
const NodePermissions& permissions = DEFAULT_AGENT_PERMISSIONS);
static bool parseSTUNResponse(udt::BasePacket* packet, QHostAddress& newPublicAddress, uint16_t& newPublicPort);

View file

@ -261,7 +261,7 @@ void PacketReceiver::handleVerifiedMessage(QSharedPointer<ReceivedMessage> recei
SharedNodePointer matchingNode;
if (receivedMessage->getSourceID() != 0) {
if (receivedMessage->getSourceID() != Node::NULL_LOCAL_ID) {
matchingNode = nodeList->nodeWithLocalID(receivedMessage->getSourceID());
}
QMutexLocker packetListenerLocker(&_packetListenerLock);

View file

@ -25,7 +25,7 @@ SequenceNumberStats::SequenceNumberStats(int statsHistoryLength, bool canDetectO
: _lastReceivedSequence(0),
_missingSet(),
_stats(),
_lastSenderID(0),
_lastSenderID(NULL_LOCAL_ID),
_statsHistory(statsHistoryLength),
_lastUnreasonableSequence(0),
_consecutiveUnreasonableOnTime(0)
@ -35,7 +35,7 @@ SequenceNumberStats::SequenceNumberStats(int statsHistoryLength, bool canDetectO
void SequenceNumberStats::reset() {
_missingSet.clear();
_stats = PacketStreamStats();
_lastSenderID = 0;
_lastSenderID = NULL_LOCAL_ID;
_statsHistory.clear();
_lastUnreasonableSequence = 0;
_consecutiveUnreasonableOnTime = 0;

View file

@ -73,7 +73,7 @@ public:
SequenceNumberStats(int statsHistoryLength = 0, bool canDetectOutOfSync = true);
void reset();
ArrivalInfo sequenceNumberReceived(quint16 incoming, NetworkLocalID senderID = 0, const bool wantExtraDebugging = false);
ArrivalInfo sequenceNumberReceived(quint16 incoming, NetworkLocalID senderID = NULL_LOCAL_ID, const bool wantExtraDebugging = false);
void pruneMissingSet(const bool wantExtraDebugging = false);
void pushStatsToHistory() { _statsHistory.insert(_stats); }
@ -101,6 +101,7 @@ private:
PacketStreamStats _stats;
NetworkLocalID _lastSenderID;
static const NetworkLocalID NULL_LOCAL_ID = (NetworkLocalID) 0;
RingBufferHistory<PacketStreamStats> _statsHistory;