2008-02-28 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

Add a file descriptor which connected to fast peer(latency<1500) 
to
	select(). This change reduced CPU load.
	* src/PeerInteractionCommand.cc
	* src/DefaultBtInteractive.{h, cc}
	* src/BtInteractive.h
pull/1/head
Tatsuhiro Tsujikawa 2008-02-28 14:27:00 +00:00
parent c766d945ef
commit a1458a1642
5 changed files with 18 additions and 1 deletions

View File

@ -1,3 +1,11 @@
2008-02-28 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Add a file descriptor which connected to fast peer(latency<1500) to
select(). This change reduced CPU load.
* src/PeerInteractionCommand.cc
* src/DefaultBtInteractive.{h, cc}
* src/BtInteractive.h
2008-02-28 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Fixed the previous insufficient fix for possible busy loop.

View File

@ -65,6 +65,8 @@ public:
virtual bool isSendingMessageInProgress() = 0;
virtual size_t countReceivedMessageInIteration() const = 0;
virtual size_t countOutstandingRequest() = 0;
};
typedef SharedHandle<BtInteractive> BtInteractiveHandle;

View File

@ -453,6 +453,11 @@ size_t DefaultBtInteractive::countReceivedMessageInIteration() const
return _numReceivedMessage;
}
size_t DefaultBtInteractive::countOutstandingRequest()
{
return dispatcher->countOutstandingRequest();
}
void DefaultBtInteractive::setPeer(const SharedHandle<Peer>& peer)
{
this->peer = peer;

View File

@ -156,6 +156,8 @@ public:
virtual size_t countReceivedMessageInIteration() const;
virtual size_t countOutstandingRequest();
void setCuid(int32_t cuid) {
this->cuid = cuid;
}

View File

@ -218,7 +218,7 @@ bool PeerInteractionCommand::executeInternal() {
if(btInteractive->countReceivedMessageInIteration() > 0) {
updateKeepAlive();
}
if(peer->amInterested() && !peer->peerChoking() ||
if(peer->amInterested() && !peer->peerChoking() && peer->getLatency() < 1500 ||
peer->peerInterested() && !peer->amChoking()) {
if(maxDownloadSpeedLimit > 0) {
TransferStat stat = peerStorage->calculateStat();