mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 19:04:32 +02:00
Merge pull request #5950 from birarda/guard-sph
guard for insert/get in SentPacketHistory
This commit is contained in:
commit
4480b60321
4 changed files with 10 additions and 3 deletions
|
@ -23,7 +23,8 @@ std::unique_ptr<NLPacketList> NLPacketList::create(PacketType packetType, QByteA
|
|||
}
|
||||
|
||||
std::unique_ptr<NLPacketList> NLPacketList::fromPacketList(std::unique_ptr<PacketList> packetList) {
|
||||
auto nlPacketList = std::unique_ptr<NLPacketList>(new NLPacketList(std::move(*packetList.release()))); nlPacketList->open(ReadOnly);
|
||||
auto nlPacketList = std::unique_ptr<NLPacketList>(new NLPacketList(std::move(*packetList.release())));
|
||||
nlPacketList->open(ReadOnly);
|
||||
return nlPacketList;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ void SentPacketHistory::packetSent(uint16_t sequenceNumber, const NLPacket& pack
|
|||
}
|
||||
_newestSequenceNumber = sequenceNumber;
|
||||
|
||||
QWriteLocker locker(&_packetsLock);
|
||||
_sentPackets.insert(NLPacket::createCopy(packet));
|
||||
}
|
||||
|
||||
|
@ -48,6 +49,7 @@ const NLPacket* SentPacketHistory::getPacket(uint16_t sequenceNumber) const {
|
|||
if (seqDiff < 0) {
|
||||
seqDiff += UINT16_RANGE;
|
||||
}
|
||||
|
||||
|
||||
QReadLocker locker(&_packetsLock);
|
||||
return _sentPackets.get(seqDiff)->get();
|
||||
}
|
||||
|
|
|
@ -12,7 +12,9 @@
|
|||
#define hifi_SentPacketHistory_h
|
||||
|
||||
#include <stdint.h>
|
||||
#include <qbytearray.h>
|
||||
|
||||
#include <QtCore/QByteArray>
|
||||
#include <QtCore/QReadWriteLock>
|
||||
|
||||
#include "NLPacket.h"
|
||||
#include "RingBufferHistory.h"
|
||||
|
@ -29,6 +31,7 @@ public:
|
|||
const NLPacket* getPacket(uint16_t sequenceNumber) const;
|
||||
|
||||
private:
|
||||
mutable QReadWriteLock _packetsLock { QReadWriteLock::Recursive };
|
||||
RingBufferHistory<std::unique_ptr<NLPacket>> _sentPackets; // circular buffer
|
||||
|
||||
uint16_t _newestSequenceNumber;
|
||||
|
|
|
@ -346,6 +346,7 @@ void OctreeEditPacketSender::processNackPacket(NLPacket& packet, SharedNodePoint
|
|||
if (_sentPacketHistories.count(sendingNode->getUUID()) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const SentPacketHistory& sentPacketHistory = _sentPacketHistories[sendingNode->getUUID()];
|
||||
|
||||
// read sequence numbers and queue packets for resend
|
||||
|
|
Loading…
Reference in a new issue