Skip to content

Commit

Permalink
RunCommandQueues: little optimization
Browse files Browse the repository at this point in the history
remove command from queue on success, else do nothing, instead of remove command from queue and push it front on success
  • Loading branch information
nerzhul committed Mar 31, 2015
1 parent 7c12172 commit ab77bf9
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/network/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit ab77bf9

Please sign in to comment.