From a1458a1642b6582c0b316e094e5008a10b4963a8 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Thu, 28 Feb 2008 14:27:00 +0000 Subject: [PATCH] 2008-02-28 Tatsuhiro Tsujikawa 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 --- ChangeLog | 8 ++++++++ src/BtInteractive.h | 2 ++ src/DefaultBtInteractive.cc | 5 +++++ src/DefaultBtInteractive.h | 2 ++ src/PeerInteractionCommand.cc | 2 +- 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 03602435..ea9637da 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-02-28 Tatsuhiro Tsujikawa + + 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 Fixed the previous insufficient fix for possible busy loop. diff --git a/src/BtInteractive.h b/src/BtInteractive.h index cb97a0c4..35f45efd 100644 --- a/src/BtInteractive.h +++ b/src/BtInteractive.h @@ -65,6 +65,8 @@ public: virtual bool isSendingMessageInProgress() = 0; virtual size_t countReceivedMessageInIteration() const = 0; + + virtual size_t countOutstandingRequest() = 0; }; typedef SharedHandle BtInteractiveHandle; diff --git a/src/DefaultBtInteractive.cc b/src/DefaultBtInteractive.cc index 50830df5..ecbc1cb6 100644 --- a/src/DefaultBtInteractive.cc +++ b/src/DefaultBtInteractive.cc @@ -453,6 +453,11 @@ size_t DefaultBtInteractive::countReceivedMessageInIteration() const return _numReceivedMessage; } +size_t DefaultBtInteractive::countOutstandingRequest() +{ + return dispatcher->countOutstandingRequest(); +} + void DefaultBtInteractive::setPeer(const SharedHandle& peer) { this->peer = peer; diff --git a/src/DefaultBtInteractive.h b/src/DefaultBtInteractive.h index a70ae31f..322445ce 100644 --- a/src/DefaultBtInteractive.h +++ b/src/DefaultBtInteractive.h @@ -156,6 +156,8 @@ public: virtual size_t countReceivedMessageInIteration() const; + virtual size_t countOutstandingRequest(); + void setCuid(int32_t cuid) { this->cuid = cuid; } diff --git a/src/PeerInteractionCommand.cc b/src/PeerInteractionCommand.cc index 34af2271..3e7a3927 100644 --- a/src/PeerInteractionCommand.cc +++ b/src/PeerInteractionCommand.cc @@ -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();