2009-05-13 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Fixed the bug that POU peers are never choked in seeding.
	* src/BtSeederStateChoke.cc
	* src/BtSeederStateChoke.h
pull/1/head
Tatsuhiro Tsujikawa 2009-05-13 14:10:20 +00:00
parent 9b9295ce4a
commit eb0cb42c72
3 changed files with 23 additions and 5 deletions

View File

@ -1,3 +1,9 @@
2009-05-13 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Fixed the bug that POU peers are never choked in seeding.
* src/BtSeederStateChoke.cc
* src/BtSeederStateChoke.h
2009-05-13 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added web-seeding URI handling in addTorrent command.

View File

@ -87,6 +87,11 @@ unsigned int BtSeederStateChoke::PeerEntry::getUploadSpeed() const
return _uploadSpeed;
}
void BtSeederStateChoke::PeerEntry::disableOptUnchoking()
{
_peer->optUnchoking(false);
}
void BtSeederStateChoke::unchoke
(std::deque<BtSeederStateChoke::PeerEntry>& peers)
{
@ -100,11 +105,16 @@ void BtSeederStateChoke::unchoke
_logger->info("RU: %s, ulspd=%u", (*r).getPeer()->ipaddr.c_str(),
(*r).getUploadSpeed());
}
if(_round == 2 && r != peers.end()) {
std::random_shuffle(r, peers.end(),
*(SimpleRandomizer::getInstance().get()));
(*r).getPeer()->optUnchoking(true);
_logger->info("POU: %s", (*r).getPeer()->ipaddr.c_str());
if(_round == 2) {
std::for_each(peers.begin(), peers.end(),
std::mem_fun_ref(&PeerEntry::disableOptUnchoking));
if(r != peers.end()) {
std::random_shuffle(r, peers.end(),
*(SimpleRandomizer::getInstance().get()));
(*r).getPeer()->optUnchoking(true);
_logger->info("POU: %s", (*r).getPeer()->ipaddr.c_str());
}
}
}

View File

@ -72,6 +72,8 @@ private:
SharedHandle<Peer> getPeer() const;
unsigned int getUploadSpeed() const;
void disableOptUnchoking();
};
void unchoke(std::deque<PeerEntry>& peers);