summaryrefslogtreecommitdiffstats
path: root/libtorrent-extended/bad_peer_handling.patch
diff options
context:
space:
mode:
Diffstat (limited to 'libtorrent-extended/bad_peer_handling.patch')
-rw-r--r--libtorrent-extended/bad_peer_handling.patch67
1 files changed, 67 insertions, 0 deletions
diff --git a/libtorrent-extended/bad_peer_handling.patch b/libtorrent-extended/bad_peer_handling.patch
new file mode 100644
index 0000000..26d9515
--- /dev/null
+++ b/libtorrent-extended/bad_peer_handling.patch
@@ -0,0 +1,67 @@
+diff --git a/src/download/choke_manager.cc b/src/download/choke_manager.cc
+index 4915a96..efda46c 100644
+--- a/src/download/choke_manager.cc
++++ b/src/download/choke_manager.cc
+@@ -193,7 +193,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 70169ad..6d9b4f9 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();
+
+ const HashString& id() const { return peer_info()->id(); }
+ const char* options() const { return peer_info()->options(); }
+diff --git a/src/torrent/peer/peer_info.h b/src/torrent/peer/peer_info.h
+index fe80027..9b17e61 100644
+--- a/src/torrent/peer/peer_info.h
++++ b/src/torrent/peer/peer_info.h
+@@ -51,6 +51,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);
+@@ -79,6 +81,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; }
+