mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 00:36:30 +02:00
lock then check size
This commit is contained in:
parent
036cb8859d
commit
6c4a36fb7f
1 changed files with 11 additions and 5 deletions
|
@ -155,11 +155,14 @@ void SendQueue::run() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there is no packet to resend, grab the next one in the list
|
// If there is no packet to resend, grab the next one in the list
|
||||||
if (!nextPacket && _packets.size() > 0) {
|
if (!nextPacket) {
|
||||||
QWriteLocker locker(&_packetsLock);
|
QWriteLocker locker(&_packetsLock);
|
||||||
|
|
||||||
|
if (_packets.size() > 0) {
|
||||||
nextPacket.swap(_packets.front());
|
nextPacket.swap(_packets.front());
|
||||||
_packets.pop_front();
|
_packets.pop_front();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (nextPacket) {
|
if (nextPacket) {
|
||||||
bool shouldSendSecondOfPair = false;
|
bool shouldSendSecondOfPair = false;
|
||||||
|
@ -194,9 +197,12 @@ void SendQueue::run() {
|
||||||
// we've detected we should send the second packet in a pair, do that now before sleeping
|
// we've detected we should send the second packet in a pair, do that now before sleeping
|
||||||
{
|
{
|
||||||
QWriteLocker locker(&_packetsLock);
|
QWriteLocker locker(&_packetsLock);
|
||||||
|
|
||||||
|
if (_packets.size() > 0) {
|
||||||
pairedPacket.swap(_packets.front());
|
pairedPacket.swap(_packets.front());
|
||||||
_packets.pop_front();
|
_packets.pop_front();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (pairedPacket) {
|
if (pairedPacket) {
|
||||||
// write this packet's sequence number and send it off
|
// write this packet's sequence number and send it off
|
||||||
|
|
Loading…
Reference in a new issue