mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-04-07 10:02:24 +02:00
Add locks to OctreeEditPacketSender to protect various members
This commit is contained in:
parent
b95515933f
commit
001eae784a
2 changed files with 7 additions and 3 deletions
|
@ -46,6 +46,7 @@ bool OctreeEditPacketSender::serversExist() const {
|
|||
void OctreeEditPacketSender::queuePacketToNode(const QUuid& nodeUUID, std::unique_ptr<NLPacket> packet) {
|
||||
|
||||
bool wantDebug = false;
|
||||
QMutexLocker lock(&_packetsQueueLock);
|
||||
DependencyManager::get<NodeList>()->eachNode([&](const SharedNodePointer& node){
|
||||
// only send to the NodeTypes that are getMyNodeType()
|
||||
if (node->getType() == getMyNodeType()
|
||||
|
@ -324,6 +325,8 @@ bool OctreeEditPacketSender::process() {
|
|||
void OctreeEditPacketSender::processNackPacket(ReceivedMessage& message, SharedNodePointer sendingNode) {
|
||||
// parse sending node from packet, retrieve packet history for that node
|
||||
|
||||
QMutexLocker lock(&_packetsQueueLock);
|
||||
|
||||
// if packet history doesn't exist for the sender node (somehow), bail
|
||||
if (_sentPacketHistories.count(sendingNode->getUUID()) == 0) {
|
||||
return;
|
||||
|
@ -345,7 +348,7 @@ void OctreeEditPacketSender::processNackPacket(ReceivedMessage& message, SharedN
|
|||
}
|
||||
|
||||
void OctreeEditPacketSender::nodeKilled(SharedNodePointer node) {
|
||||
// TODO: add locks
|
||||
QMutexLocker lock(&_packetsQueueLock);
|
||||
QUuid nodeUUID = node->getUUID();
|
||||
_pendingEditPackets.erase(nodeUUID);
|
||||
_outgoingSequenceNumbers.erase(nodeUUID);
|
||||
|
|
|
@ -86,19 +86,20 @@ protected:
|
|||
void processPreServerExistsPackets();
|
||||
|
||||
// These are packets which are destined from know servers but haven't been released because they're still too small
|
||||
// protected by _packetsQueueLock
|
||||
std::unordered_map<QUuid, PacketOrPacketList> _pendingEditPackets;
|
||||
|
||||
// These are packets that are waiting to be processed because we don't yet know if there are servers
|
||||
int _maxPendingMessages;
|
||||
bool _releaseQueuedMessagesPending;
|
||||
QMutex _pendingPacketsLock;
|
||||
QMutex _packetsQueueLock; // don't let different threads release the queue while another thread is writing to it
|
||||
QMutex _packetsQueueLock{ QMutex::Recursive }; // don't let different threads release the queue while another thread is writing to it
|
||||
std::list<EditMessagePair> _preServerEdits; // these will get packed into other larger packets
|
||||
std::list<std::unique_ptr<NLPacket>> _preServerSingleMessagePackets; // these will go out as is
|
||||
|
||||
QMutex _releaseQueuedPacketMutex;
|
||||
|
||||
// TODO: add locks for this and _pendingEditPackets
|
||||
// protected by _packetsQueueLock
|
||||
std::unordered_map<QUuid, SentPacketHistory> _sentPacketHistories;
|
||||
std::unordered_map<QUuid, quint16> _outgoingSequenceNumbers;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue