updated on Thu Jan 12 04:00:44 UTC 2012
[aur-mirror.git] / libtorrent-extended / ex_bad_peer_handling.patch
blob4285fa1ead48782a081ef40eeb0980a153dba195
1 diff --git a/src/download/choke_manager.cc b/src/download/choke_manager.cc
2 index 3c422c0..17f4010 100644
3 --- a/src/download/choke_manager.cc
4 +++ b/src/download/choke_manager.cc
5 @@ -200,7 +200,8 @@ ChokeManager::set_snubbed(PeerConnectionBase* pc, ChokeManagerNode* base) {
6 choke_manager_erase(&m_queued, pc);
9 - base->set_queued(false);
10 + //breaks unsnubbing, ticket #989:
11 + //base->set_queued(false);
14 void
15 diff --git a/src/torrent/peer/peer.cc b/src/torrent/peer/peer.cc
16 index 3f29f82..a15a7b2 100644
17 --- a/src/torrent/peer/peer.cc
18 +++ b/src/torrent/peer/peer.cc
19 @@ -63,7 +63,8 @@ bool Peer::is_down_interested() const { return c_ptr()->is_up_interested();
21 bool Peer::is_snubbed() const { return c_ptr()->is_up_snubbed(); }
22 void Peer::set_snubbed(bool v) { m_ptr()->set_upload_snubbed(v); }
23 -void Peer::set_banned() { m_peerInfo->set_failed_counter(64); }
24 +void Peer::set_banned() { m_peerInfo->set_banned(); }
25 +void Peer::set_unbanned() { m_peerInfo->set_unbanned(); }
27 const Rate* Peer::down_rate() const { return c_ptr()->c_peer_chunks()->download_throttle()->rate(); }
28 const Rate* Peer::up_rate() const { return c_ptr()->c_peer_chunks()->upload_throttle()->rate(); }
29 diff --git a/src/torrent/peer/peer.h b/src/torrent/peer/peer.h
30 index 13e2880..e03bda4 100644
31 --- a/src/torrent/peer/peer.h
32 +++ b/src/torrent/peer/peer.h
33 @@ -69,7 +69,10 @@ public:
35 bool is_snubbed() const;
36 void set_snubbed(bool v);
38 + bool is_banned() const { return peer_info()->is_banned(); }
39 void set_banned();
40 + void set_unbanned();
42 bool is_friend() const { return peer_info()->is_friend(); }
44 diff --git a/src/torrent/peer/peer_info.h b/src/torrent/peer/peer_info.h
45 index 8f56f73..5a6fe22 100644
46 --- a/src/torrent/peer/peer_info.h
47 +++ b/src/torrent/peer/peer_info.h
48 @@ -55,6 +55,8 @@ public:
49 friend class PeerList;
50 friend class ProtocolExtension;
52 + static const unsigned int banned_mask = 4096;
54 static const int flag_connected = (1 << 0);
55 static const int flag_incoming = (1 << 1);
56 static const int flag_handshake = (1 << 2);
57 @@ -88,6 +90,10 @@ public:
58 uint32_t failed_counter() const { return m_failedCounter; }
59 void set_failed_counter(uint32_t c) { m_failedCounter = c; }
61 + bool is_banned() const { return m_failedCounter & banned_mask; }
62 + void set_banned() { m_failedCounter |= banned_mask; }
63 + void set_unbanned() { m_failedCounter &= ~banned_mask; }
65 uint32_t transfer_counter() const { return m_transferCounter; }
66 void set_transfer_counter(uint32_t c) { m_transferCounter = c; }