repairs for NetworkPacket removal

This commit is contained in:
Stephen Birarda 2015-07-07 17:50:32 -07:00
parent 1cfa65a3df
commit 7a9dbd7f2f
2 changed files with 9 additions and 8 deletions

View file

@ -267,19 +267,20 @@ bool PacketSender::nonThreadedProcess() {
while ((packetsSentThisCall < packetsToSendThisCall) && (packetsLeft > 0)) { while ((packetsSentThisCall < packetsToSendThisCall) && (packetsLeft > 0)) {
lock(); lock();
NodePacketPair& packetPair = _packets.pop_front(); NodePacketPair packetPair = std::move(_packets.front());
_packets.pop_front();
packetsLeft = _packets.size(); packetsLeft = _packets.size();
unlock(); unlock();
// send the packet through the NodeList... // send the packet through the NodeList...
DependencyManager::get<NodeList>()->sendUnreliablePacket(packetPair->second(), packetPair->first()); DependencyManager::get<NodeList>()->sendUnreliablePacket(packetPair.second, packetPair.first);
packetsSentThisCall++; packetsSentThisCall++;
_packetsOverCheckInterval++; _packetsOverCheckInterval++;
_totalPacketsSent++; _totalPacketsSent++;
int packetSize = packetPair->second()->getSizeWithHeader(); int packetSize = packetPair.second->getSizeWithHeader();
_totalBytesSent += packetSize; _totalBytesSent += packetSize;
emit packetSent(packetSize); emit packetSent(packetSize);

View file

@ -47,19 +47,19 @@ bool ReceivedPacketProcessor::process() {
} }
lock(); lock();
QVector<NetworkPacket> currentPackets; std::list<NodePacketPair> currentPackets;
currentPackets.swap(_packets); currentPackets.swap(_packets);
unlock(); unlock();
foreach(auto& packet, currentPackets) { foreach(auto& packetPair, currentPackets) {
// TODO: Replace QByteArray() once NLPacket is coming through on receive side // TODO: Replace QByteArray() once NLPacket is coming through on receive side
processPacket(packet->first(), QByteArray()); processPacket(packetPair.first, QByteArray());
midProcess(); midProcess();
} }
lock(); lock();
foreach(auto& packet, currentPackets) { foreach(auto& packetPair, currentPackets) {
_nodePacketCounts[packet.getNode()->getUUID()]--; _nodePacketCounts[packetPair.first->getUUID()]--;
} }
unlock(); unlock();