diff --git a/src/download/choke_manager.cc b/src/download/choke_manager.cc index 3c422c0..17f4010 100644 --- a/src/download/choke_manager.cc +++ b/src/download/choke_manager.cc @@ -200,7 +200,8 @@ ChokeManager::set_snubbed(PeerConnectionBase* pc, ChokeManagerNode* base) { choke_manager_erase(&m_queued, pc); } - base->set_queued(false); + //breaks unsnubbing, ticket #989: + //base->set_queued(false); } void diff --git a/src/torrent/peer/peer.cc b/src/torrent/peer/peer.cc index 3f29f82..a15a7b2 100644 --- a/src/torrent/peer/peer.cc +++ b/src/torrent/peer/peer.cc @@ -63,7 +63,8 @@ bool Peer::is_down_interested() const { return c_ptr()->is_up_interested(); bool Peer::is_snubbed() const { return c_ptr()->is_up_snubbed(); } void Peer::set_snubbed(bool v) { m_ptr()->set_upload_snubbed(v); } -void Peer::set_banned() { m_peerInfo->set_failed_counter(64); } +void Peer::set_banned() { m_peerInfo->set_banned(); } +void Peer::set_unbanned() { m_peerInfo->set_unbanned(); } const Rate* Peer::down_rate() const { return c_ptr()->c_peer_chunks()->download_throttle()->rate(); } const Rate* Peer::up_rate() const { return c_ptr()->c_peer_chunks()->upload_throttle()->rate(); } diff --git a/src/torrent/peer/peer.h b/src/torrent/peer/peer.h index 13e2880..e03bda4 100644 --- a/src/torrent/peer/peer.h +++ b/src/torrent/peer/peer.h @@ -69,7 +69,10 @@ public: bool is_snubbed() const; void set_snubbed(bool v); + + bool is_banned() const { return peer_info()->is_banned(); } void set_banned(); + void set_unbanned(); bool is_friend() const { return peer_info()->is_friend(); } diff --git a/src/torrent/peer/peer_info.h b/src/torrent/peer/peer_info.h index 8f56f73..5a6fe22 100644 --- a/src/torrent/peer/peer_info.h +++ b/src/torrent/peer/peer_info.h @@ -55,6 +55,8 @@ public: friend class PeerList; friend class ProtocolExtension; + static const unsigned int banned_mask = 4096; + static const int flag_connected = (1 << 0); static const int flag_incoming = (1 << 1); static const int flag_handshake = (1 << 2); @@ -88,6 +90,10 @@ public: uint32_t failed_counter() const { return m_failedCounter; } void set_failed_counter(uint32_t c) { m_failedCounter = c; } + bool is_banned() const { return m_failedCounter & banned_mask; } + void set_banned() { m_failedCounter |= banned_mask; } + void set_unbanned() { m_failedCounter &= ~banned_mask; } + uint32_t transfer_counter() const { return m_transferCounter; } void set_transfer_counter(uint32_t c) { m_transferCounter = c; }