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

Try to keep the ordering of outgoing piece message.
	* src/DefaultBtMessageDispatcher.cc
	(DefaultBtMessageDispatcher::sendMessages)
pull/1/head
Tatsuhiro Tsujikawa 2008-06-04 15:53:47 +00:00
parent bc5319081b
commit 20f5fcfc0f
2 changed files with 17 additions and 1 deletions

View File

@ -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> 2008-06-05 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Fixed busy loop when error/hup epoll events occur. Fixed busy loop when error/hup epoll events occur.

View File

@ -98,7 +98,17 @@ void DefaultBtMessageDispatcher::sendMessages() {
break; 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 { class HandleEvent {