lock then check size

This commit is contained in:
Stephen Birarda 2015-07-30 18:22:43 -07:00
parent 036cb8859d
commit 6c4a36fb7f

View file

@ -155,10 +155,13 @@ void SendQueue::run() {
}
// If there is no packet to resend, grab the next one in the list
if (!nextPacket && _packets.size() > 0) {
if (!nextPacket) {
QWriteLocker locker(&_packetsLock);
nextPacket.swap(_packets.front());
_packets.pop_front();
if (_packets.size() > 0) {
nextPacket.swap(_packets.front());
_packets.pop_front();
}
}
if (nextPacket) {
@ -194,8 +197,11 @@ void SendQueue::run() {
// we've detected we should send the second packet in a pair, do that now before sleeping
{
QWriteLocker locker(&_packetsLock);
pairedPacket.swap(_packets.front());
_packets.pop_front();
if (_packets.size() > 0) {
pairedPacket.swap(_packets.front());
_packets.pop_front();
}
}
if (pairedPacket) {