summaryrefslogtreecommitdiff
path: root/src/network/connection.cpp
diff options
context:
space:
mode:
authorLoic Blot <loic.blot@unix-experience.fr>2015-03-29 10:49:43 +0200
committerLoic Blot <loic.blot@unix-experience.fr>2015-03-29 10:49:43 +0200
commitdfe00abc5addd66dbf840d7e826690291f4afd93 (patch)
tree4812065839e27a258e929dfc26d713ff8d0e8818 /src/network/connection.cpp
parent3444dec2db30b8aa8a4e9c268fdba2f84b870ce3 (diff)
downloadminetest-dfe00abc5addd66dbf840d7e826690291f4afd93.tar.gz
minetest-dfe00abc5addd66dbf840d7e826690291f4afd93.tar.bz2
minetest-dfe00abc5addd66dbf840d7e826690291f4afd93.zip
queued_commands must be a std::deque. RunCommandQueues needs to push packet on front, not back
Diffstat (limited to 'src/network/connection.cpp')
-rw-r--r--src/network/connection.cpp20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/network/connection.cpp b/src/network/connection.cpp
index d51324ed4..4440b8cc7 100644
--- a/src/network/connection.cpp
+++ b/src/network/connection.cpp
@@ -1063,14 +1063,14 @@ void UDPPeer::PutReliableSendCommand(ConnectionCommand &c,
<<" processing reliable command for peer id: " << c.peer_id
<<" data size: " << c.data.getSize() << std::endl);
if (!processReliableSendCommand(c,max_packet_size)) {
- channels[c.channelnum].queued_commands.push(c);
+ channels[c.channelnum].queued_commands.push_back(c);
}
}
else {
LOG(dout_con<<m_connection->getDesc()
<<" Queueing reliable command for peer id: " << c.peer_id
<<" data size: " << c.data.getSize() <<std::endl);
- channels[c.channelnum].queued_commands.push(c);
+ channels[c.channelnum].queued_commands.push_back(c);
}
}
@@ -1182,17 +1182,15 @@ void UDPPeer::RunCommandQueues(
unsigned int maxtransfer)
{
- for (unsigned int i = 0; i < CHANNEL_COUNT; i++)
- {
+ for (unsigned int i = 0; i < CHANNEL_COUNT; i++) {
unsigned int commands_processed = 0;
if ((channels[i].queued_commands.size() > 0) &&
(channels[i].queued_reliables.size() < maxtransfer) &&
- (commands_processed < maxcommands))
- {
+ (commands_processed < maxcommands)) {
try {
ConnectionCommand c = channels[i].queued_commands.front();
- channels[i].queued_commands.pop();
+ channels[i].queued_commands.pop_front();
LOG(dout_con<<m_connection->getDesc()
<<" processing queued reliable command "<<std::endl);
if (!processReliableSendCommand(c,max_packet_size)) {
@@ -1200,7 +1198,7 @@ void UDPPeer::RunCommandQueues(
<< " Failed to queue packets for peer_id: " << c.peer_id
<< ", delaying sending of " << c.data.getSize()
<< " bytes" << std::endl);
- channels[i].queued_commands.push(c);
+ channels[i].queued_commands.push_front(c);
}
}
catch (ItemNotFoundException &e) {
@@ -1328,12 +1326,10 @@ bool ConnectionSendThread::packetsQueued()
if (dynamic_cast<UDPPeer*>(&peer) == 0)
continue;
- for(u16 i=0; i<CHANNEL_COUNT; i++)
- {
+ for(u16 i=0; i < CHANNEL_COUNT; i++) {
Channel *channel = &(dynamic_cast<UDPPeer*>(&peer))->channels[i];
- if (channel->queued_commands.size() > 0)
- {
+ if (channel->queued_commands.size() > 0) {
return true;
}
}