aboutsummaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorLoic Blot <loic.blot@unix-experience.fr>2015-03-31 09:22:44 +0200
committerLoic Blot <loic.blot@unix-experience.fr>2015-03-31 09:29:33 +0200
commitab77bf98ee320835e5dc50ed9b013442221f96e8 (patch)
tree7b9ce9657c13543b874f5fcd99816c7e74f45d50 /src/network
parent7c121726dc9e334208f3a7585db86bc717a4a83e (diff)
downloadminetest-ab77bf98ee320835e5dc50ed9b013442221f96e8.tar.gz
minetest-ab77bf98ee320835e5dc50ed9b013442221f96e8.tar.bz2
minetest-ab77bf98ee320835e5dc50ed9b013442221f96e8.zip
RunCommandQueues: little optimization
remove command from queue on success, else do nothing, instead of remove command from queue and push it front on success
Diffstat (limited to 'src/network')
-rw-r--r--src/network/connection.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/network/connection.cpp b/src/network/connection.cpp
index 5ea739dd4..b808c3ab6 100644
--- a/src/network/connection.cpp
+++ b/src/network/connection.cpp
@@ -1190,15 +1190,18 @@ void UDPPeer::RunCommandQueues(
(commands_processed < maxcommands)) {
try {
ConnectionCommand c = channels[i].queued_commands.front();
- channels[i].queued_commands.pop_front();
- LOG(dout_con<<m_connection->getDesc()
- <<" processing queued reliable command "<<std::endl);
- if (!processReliableSendCommand(c,max_packet_size)) {
- LOG(dout_con<<m_connection->getDesc()
+
+ LOG(dout_con << m_connection->getDesc()
+ << " processing queued reliable command " << std::endl);
+
+ // Packet is processed, remove it from queue
+ if (processReliableSendCommand(c,max_packet_size)) {
+ channels[i].queued_commands.pop_front();
+ } else {
+ LOG(dout_con << m_connection->getDesc()
<< " Failed to queue packets for peer_id: " << c.peer_id
<< ", delaying sending of " << c.data.getSize()
<< " bytes" << std::endl);
- channels[i].queued_commands.push_front(c);
}
}
catch (ItemNotFoundException &e) {