Explorar el Código

2008-06-05 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

	Try to keep the ordering of outgoing piece message.
	* src/DefaultBtMessageDispatcher.cc
	(DefaultBtMessageDispatcher::sendMessages)
Tatsuhiro Tsujikawa hace 17 años
padre
commit
20f5fcfc0f
Se han modificado 2 ficheros con 17 adiciones y 1 borrados
  1. 6 0
      ChangeLog
  2. 11 1
      src/DefaultBtMessageDispatcher.cc

+ 6 - 0
ChangeLog

@@ -1,3 +1,9 @@
+2008-06-05  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
+
+	Try to keep the ordering of outgoing piece message.
+	* src/DefaultBtMessageDispatcher.cc
+	(DefaultBtMessageDispatcher::sendMessages)
+
 2008-06-05  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 
 	Fixed busy loop when error/hup epoll events occur.

+ 11 - 1
src/DefaultBtMessageDispatcher.cc

@@ -98,7 +98,17 @@ void DefaultBtMessageDispatcher::sendMessages() {
       break;
     }
   }
-  messageQueue.insert(messageQueue.end(), tempQueue.begin(), tempQueue.end());
+  if(!tempQueue.empty()) {
+    // Insert pending message to the front, so that message is likely sent in
+    // the same order as it is queued.
+    if(!messageQueue.empty() && messageQueue.front()->isSendingInProgress()) {
+      messageQueue.insert(messageQueue.begin()+1,
+			  tempQueue.begin(), tempQueue.end());
+    } else {
+      messageQueue.insert(messageQueue.begin(),
+			  tempQueue.begin(), tempQueue.end());
+    }
+  }
 }
 
 class HandleEvent {