From afdccf84ab3bbb3ef80cdadd566d5570b849375e Mon Sep 17 00:00:00 2001 From: Marcos Pinto Date: Wed, 26 Mar 2008 08:59:33 +0000 Subject: [PATCH] tag 0.5.8.7 --- ChangeLog | 7 +- glade/delugegtk.glade | 1807 +++++++++-------- .../libtorrent/kademlia/dht_tracker.hpp | 7 + .../kademlia/traversal_algorithm.hpp | 7 +- libtorrent/src/bt_peer_connection.cpp | 5 - libtorrent/src/kademlia/closest_nodes.cpp | 7 +- libtorrent/src/kademlia/dht_tracker.cpp | 15 +- libtorrent/src/kademlia/node.cpp | 17 + libtorrent/src/kademlia/routing_table.cpp | 3 +- .../src/kademlia/traversal_algorithm.cpp | 17 +- libtorrent/src/peer_connection.cpp | 1 + libtorrent/src/session_impl.cpp | 2 +- setup.py | 2 +- src/common.py | 2 +- 14 files changed, 970 insertions(+), 929 deletions(-) diff --git a/ChangeLog b/ChangeLog index e83c3853f..3b5edcaff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,10 @@ -Deluge 0.5.8.7 (xx March 2008) +Deluge 0.5.8.7 (25 March 2008) * UPnP fixes * Bandwidth limiter fix - * DHT routing table fix + * Various DHT fixes + * Fix upload ratio not saving + * Fix WebUI crash (ticket #89) + * Clear seeding torrents now deletes the ".torrent" file * Fix keyboard scrolling of plugins * Scheduler can now handle number of active torrents, upload slots and max connections - Ben diff --git a/glade/delugegtk.glade b/glade/delugegtk.glade index 5204d6705..9d647443a 100644 --- a/glade/delugegtk.glade +++ b/glade/delugegtk.glade @@ -19,162 +19,785 @@ - + True - GTK_ICON_SIZE_SMALL_TOOLBAR - True - - True - Add Torrent - Add - True - gtk-add - - - - False - - - - - True - False - Remove Torrent - Remove - True - gtk-remove - - - - False - - - - - True - Clear Seeding Torrents - Clear - True - gtk-clear - - - - False - - - - - True - - - False - False - - - - - True - False - Start or Resume Torrent - Resume - True - gtk-media-play - - - - False - - - - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - Pause Torrent - Pause - gtk-media-pause - + + + True + False + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + + + True + True + True + True + False + + + + - False + True + False - - True - False - Queue Torrent Up - Up - True - gtk-go-up - - - - False - - - - - True - False - Queue Torrent Down - Down - True - gtk-go-down - - - - False - - - - - True - - - False - False - - - - - True - Change Deluge preferences - Preferences - True - gtk-preferences - - - - False - - - - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - Plugins - gtk-disconnect - + + + True + False + True + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + GTK_POLICY_AUTOMATIC + GTK_POLICY_NEVER + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + GTK_RESIZE_QUEUE + GTK_SHADOW_NONE + + + True + 1 + 2 + 10 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 10 + 10 + 15 + 15 + + + True + 7 + 2 + 2 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + True + PANGO_WRAP_CHAR + True + + + 1 + 2 + 1 + 2 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + <b>Path:</b> + True + + + + + 1 + 2 + GTK_FILL + + + + + True + 0 + True + True + + + 1 + 2 + 6 + 7 + + + + + + True + 0 + True + PANGO_WRAP_CHAR + True + + + 1 + 2 + 5 + 6 + + + + + + True + 0 + True + PANGO_WRAP_CHAR + True + + + 1 + 2 + 4 + 5 + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + + + True + 0 + 0 + 1 + <b>Name:</b> + True + + + + + GTK_FILL + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + + + True + 0 + 1 + <b>Next Announce:</b> + True + + + + + 6 + 7 + GTK_FILL + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + + + True + 0 + 1 + <b>Tracker Status:</b> + True + + + + + 5 + 6 + GTK_FILL + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + + + True + 0 + 1 + <b>Tracker:</b> + True + + + + + 4 + 5 + GTK_FILL + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + + + True + 0 + 1 + <b>Total Size:</b> + True + + + + + 2 + 3 + GTK_FILL + + + + + True + 0 + True + PANGO_WRAP_CHAR + True + + + 1 + 2 + + + + + + True + 0 + True + + + 1 + 2 + 2 + 3 + + + + + + True + 0 + True + + + 1 + 2 + 3 + 4 + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + + + True + 0 + 1 + <b># of files:</b> + True + + + + + 3 + 4 + GTK_FILL + + + + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + <b>Torrent Info</b> + True + + + label_item + + + + + 1 + 2 + GTK_FILL + + + + + True + 0 + + + True + 10 + 10 + 15 + 15 + + + True + 5 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + GTK_RESIZE_QUEUE + GTK_SHADOW_NONE + + + 25 + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + + + + + + True + 0.10000000149 + + + False + False + 1 + + + + + True + 5 + 4 + 5 + + + True + 0 + True + PANGO_WRAP_WORD_CHAR + + + 3 + 4 + 4 + 5 + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 15 + 5 + + + True + 0 + 1 + <b>Availability:</b> + True + + + + + 2 + 3 + 4 + 5 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + + + True + 0 + + + + + 1 + 2 + 4 + 5 + + + + + True + 0 + 1 + <b>Pieces:</b> + True + + + 4 + 5 + + + + + True + 15 + 5 + + + True + 0 + <b>ETA:</b> + True + + + + + 2 + 3 + 3 + 4 + + + + + True + 15 + 5 + + + True + 0 + <b>Peers:</b> + True + + + + + 2 + 3 + 2 + 3 + + + + + True + 15 + 5 + + + True + 0 + <b>Speed:</b> + True + + + + + 2 + 3 + 1 + 2 + + + + + True + 15 + 5 + + + True + 0 + <b>Speed:</b> + True + + + + + 2 + 3 + + + + + True + 5 + + + True + 0 + <b>Share Ratio:</b> + True + + + + + 3 + 4 + + + + + True + 5 + + + True + 0 + <b>Seeders:</b> + True + + + + + 2 + 3 + + + + + True + 5 + + + True + 0 + <b>Uploaded:</b> + True + + + + + 1 + 2 + + + + + True + 5 + + + True + 0 + <b>Downloaded:</b> + True + + + + + + + True + 0 + + + 3 + 4 + 3 + 4 + + + + + True + 0 + + + 1 + 2 + 3 + 4 + + + + + True + 0 + + + 3 + 4 + 2 + 3 + + + + + True + 0 + + + 1 + 2 + 2 + 3 + + + + + True + 0 + + + 3 + 4 + 1 + 2 + + + + + True + 0 + + + 1 + 2 + 1 + 2 + + + + + True + 0 + + + 3 + 4 + + + + + True + 0 + + + 1 + 2 + + + + + False + 2 + + + + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + <b>Statistics</b> + True + + + label_item + + + + + + GTK_FILL + + + + + + + + + True + + + + + True + Details + + + tab + False + + + + - False - - - - - True - - - False - False + False + False - 1 - 2 - GTK_FILL + 3 + 2 + 3 + + + + + True + + + 3 + 3 + 4 + @@ -576,785 +1199,163 @@ - - True - - - 3 - 3 - 4 - - - - - + True + GTK_TOOLBAR_ICONS + GTK_ICON_SIZE_SMALL_TOOLBAR + True - + True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - - - True - False - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - - - True - True - True - True - False - - - - + Add Torrent + Add + True + gtk-add + - True - False + False - + True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - - - True - False - True - - - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - GTK_POLICY_AUTOMATIC - GTK_POLICY_NEVER - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - GTK_RESIZE_QUEUE - GTK_SHADOW_NONE - - - True - 1 - 2 - 10 - - - True - 0 - - - True - 10 - 10 - 15 - 15 - - - True - 5 - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - GTK_RESIZE_QUEUE - GTK_SHADOW_NONE - - - 25 - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - - - - - - - - True - 0.10000000149 - - - False - False - 1 - - - - - True - 5 - 4 - 5 - - - True - 0 - - - 1 - 2 - - - - - True - 0 - - - 3 - 4 - - - - - True - 0 - - - 1 - 2 - 1 - 2 - - - - - True - 0 - - - 3 - 4 - 1 - 2 - - - - - True - 0 - - - 1 - 2 - 2 - 3 - - - - - True - 0 - - - 3 - 4 - 2 - 3 - - - - - True - 0 - - - 1 - 2 - 3 - 4 - - - - - True - 0 - - - 3 - 4 - 3 - 4 - - - - - True - 5 - - - True - 0 - <b>Downloaded:</b> - True - - - - - - - True - 5 - - - True - 0 - <b>Uploaded:</b> - True - - - - - 1 - 2 - - - - - True - 5 - - - True - 0 - <b>Seeders:</b> - True - - - - - 2 - 3 - - - - - True - 5 - - - True - 0 - <b>Share Ratio:</b> - True - - - - - 3 - 4 - - - - - True - 15 - 5 - - - True - 0 - <b>Speed:</b> - True - - - - - 2 - 3 - - - - - True - 15 - 5 - - - True - 0 - <b>Speed:</b> - True - - - - - 2 - 3 - 1 - 2 - - - - - True - 15 - 5 - - - True - 0 - <b>Peers:</b> - True - - - - - 2 - 3 - 2 - 3 - - - - - True - 15 - 5 - - - True - 0 - <b>ETA:</b> - True - - - - - 2 - 3 - 3 - 4 - - - - - True - 0 - 1 - <b>Pieces:</b> - True - - - 4 - 5 - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 5 - - - True - 0 - - - - - 1 - 2 - 4 - 5 - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 15 - 5 - - - True - 0 - 1 - <b>Availability:</b> - True - - - - - 2 - 3 - 4 - 5 - - - - - True - 0 - True - PANGO_WRAP_WORD_CHAR - - - 3 - 4 - 4 - 5 - - - - - - False - 2 - - - - - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - <b>Statistics</b> - True - - - label_item - - - - - - GTK_FILL - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 10 - 10 - 15 - 15 - - - True - 7 - 2 - 2 - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 5 - - - True - 0 - 1 - <b># of files:</b> - True - - - - - 3 - 4 - GTK_FILL - - - - - True - 0 - True - - - 1 - 2 - 3 - 4 - - - - - - True - 0 - True - - - 1 - 2 - 2 - 3 - - - - - - True - 0 - True - PANGO_WRAP_CHAR - True - - - 1 - 2 - - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 5 - - - True - 0 - 1 - <b>Total Size:</b> - True - - - - - 2 - 3 - GTK_FILL - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 5 - - - True - 0 - 1 - <b>Tracker:</b> - True - - - - - 4 - 5 - GTK_FILL - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 5 - - - True - 0 - 1 - <b>Tracker Status:</b> - True - - - - - 5 - 6 - GTK_FILL - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 5 - - - True - 0 - 1 - <b>Next Announce:</b> - True - - - - - 6 - 7 - GTK_FILL - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 5 - - - True - 0 - 0 - 1 - <b>Name:</b> - True - - - - - GTK_FILL - - - - - True - 0 - True - PANGO_WRAP_CHAR - True - - - 1 - 2 - 4 - 5 - - - - - - True - 0 - True - PANGO_WRAP_CHAR - True - - - 1 - 2 - 5 - 6 - - - - - - True - 0 - True - True - - - 1 - 2 - 6 - 7 - - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 5 - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - <b>Path:</b> - True - - - - - 1 - 2 - GTK_FILL - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - True - PANGO_WRAP_CHAR - True - - - 1 - 2 - 1 - 2 - - - - - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - <b>Torrent Info</b> - True - - - label_item - - - - - 1 - 2 - GTK_FILL - - - - - - - - - True - - - - - True - Details - - - tab - False - - - - + False + Remove Torrent + Remove + True + gtk-remove + - False - False + False + + + + + True + Clear Seeding Torrents + Clear + True + gtk-clear + + + + False + + + + + True + + + False + False + + + + + True + False + Start or Resume Torrent + Resume + True + gtk-media-play + + + + False + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Pause Torrent + Pause + gtk-media-pause + + + + False + + + + + True + False + Queue Torrent Up + Up + True + gtk-go-up + + + + False + + + + + True + False + Queue Torrent Down + Down + True + gtk-go-down + + + + False + + + + + True + + + False + False + + + + + True + Change Deluge preferences + Preferences + True + gtk-preferences + + + + False + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Plugins + gtk-disconnect + + + + False + + + + + True + + + False + False - 3 - 2 - 3 + 1 + 2 + GTK_FILL diff --git a/libtorrent/include/libtorrent/kademlia/dht_tracker.hpp b/libtorrent/include/libtorrent/kademlia/dht_tracker.hpp index c032c19d1..6882d34bb 100644 --- a/libtorrent/include/libtorrent/kademlia/dht_tracker.hpp +++ b/libtorrent/include/libtorrent/kademlia/dht_tracker.hpp @@ -45,6 +45,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include #include "libtorrent/kademlia/node.hpp" #include "libtorrent/kademlia/node_id.hpp" @@ -125,6 +126,12 @@ namespace libtorrent { namespace dht dht_settings const& m_settings; int m_refresh_bucket; + // The mutex is used to abort the dht node + // it's only used to set m_abort to true + typedef boost::mutex mutex_t; + mutable mutex_t m_mutex; + bool m_abort; + // used to resolve hostnames for nodes udp::resolver m_host_resolver; diff --git a/libtorrent/include/libtorrent/kademlia/traversal_algorithm.hpp b/libtorrent/include/libtorrent/kademlia/traversal_algorithm.hpp index b333b385e..74d79edc9 100644 --- a/libtorrent/include/libtorrent/kademlia/traversal_algorithm.hpp +++ b/libtorrent/include/libtorrent/kademlia/traversal_algorithm.hpp @@ -84,12 +84,11 @@ protected: struct result { result(node_id const& id, udp::endpoint addr, unsigned char f = 0) - : id(id), addr(addr), flags(f) - {} + : id(id), addr(addr), flags(f) {} node_id id; udp::endpoint addr; - enum { queried = 1, initial = 2 }; + enum { queried = 1, initial = 2, no_id = 4 }; unsigned char flags; }; @@ -150,7 +149,7 @@ traversal_algorithm::traversal_algorithm( for (routing_table::router_iterator i = table.router_begin() , end(table.router_end()); i != end; ++i) { - add_entry(generate_id(), *i, result::initial); + add_entry(node_id(0), *i, result::initial); } } diff --git a/libtorrent/src/bt_peer_connection.cpp b/libtorrent/src/bt_peer_connection.cpp index b1884496b..e76c652cb 100755 --- a/libtorrent/src/bt_peer_connection.cpp +++ b/libtorrent/src/bt_peer_connection.cpp @@ -1594,11 +1594,6 @@ namespace libtorrent , boost::bind(&session_impl::free_disk_buffer , boost::ref(m_ses), _1)); -/* - buffer::interval i = allocate_send_buffer(r.length); - std::memcpy(i.begin, buffer, r.length); - t->filesystem().free_buffer(buffer); -*/ m_payloads.push_back(range(send_buffer_size() - r.length, r.length)); setup_send(); } diff --git a/libtorrent/src/kademlia/closest_nodes.cpp b/libtorrent/src/kademlia/closest_nodes.cpp index 7551e806f..a11fe2559 100644 --- a/libtorrent/src/kademlia/closest_nodes.cpp +++ b/libtorrent/src/kademlia/closest_nodes.cpp @@ -110,12 +110,13 @@ void closest_nodes::invoke(node_id const& id, udp::endpoint addr) void closest_nodes::done() { std::vector results; - int result_size = m_table.bucket_size(); - if (result_size > (int)m_results.size()) result_size = (int)m_results.size(); + int num_results = m_table.bucket_size(); for (std::vector::iterator i = m_results.begin() - , end(m_results.begin() + result_size); i != end; ++i) + , end(m_results.end()); i != end && num_results >= 0; ++i) { + if (i->flags & result::no_id) continue; results.push_back(node_entry(i->id, i->addr)); + --num_results; } m_done_callback(results); } diff --git a/libtorrent/src/kademlia/dht_tracker.cpp b/libtorrent/src/kademlia/dht_tracker.cpp index fe6a516ba..56bc765de 100644 --- a/libtorrent/src/kademlia/dht_tracker.cpp +++ b/libtorrent/src/kademlia/dht_tracker.cpp @@ -158,6 +158,7 @@ namespace libtorrent { namespace dht , m_refresh_timer(ios) , m_settings(settings) , m_refresh_bucket(160) + , m_abort(false) , m_host_resolver(ios) , m_refs(0) { @@ -220,6 +221,8 @@ namespace libtorrent { namespace dht void dht_tracker::stop() { + mutex_t::scoped_lock l(m_mutex); + m_abort = true; m_timer.cancel(); m_connection_timer.cancel(); m_refresh_timer.cancel(); @@ -237,7 +240,9 @@ namespace libtorrent { namespace dht void dht_tracker::connection_timeout(asio::error_code const& e) try { - if (e) return; + mutex_t::scoped_lock l(m_mutex); + if (e || m_abort) return; + if (!m_socket.is_open()) return; time_duration d = m_dht.connection_timeout(); m_connection_timer.expires_from_now(d); @@ -255,7 +260,9 @@ namespace libtorrent { namespace dht void dht_tracker::refresh_timeout(asio::error_code const& e) try { - if (e) return; + mutex_t::scoped_lock l(m_mutex); + if (e || m_abort) return; + if (!m_socket.is_open()) return; time_duration d = m_dht.refresh_timeout(); m_refresh_timer.expires_from_now(d); @@ -281,7 +288,9 @@ namespace libtorrent { namespace dht void dht_tracker::tick(asio::error_code const& e) try { - if (e) return; + mutex_t::scoped_lock l(m_mutex); + if (e || m_abort) return; + if (!m_socket.is_open()) return; m_timer.expires_from_now(minutes(tick_period)); m_timer.async_wait(m_strand.wrap(bind(&dht_tracker::tick, self(), _1))); diff --git a/libtorrent/src/kademlia/node.cpp b/libtorrent/src/kademlia/node.cpp index d4b343519..60dfa2d20 100644 --- a/libtorrent/src/kademlia/node.cpp +++ b/libtorrent/src/kademlia/node.cpp @@ -174,6 +174,12 @@ void node_impl::refresh(node_id const& id void node_impl::bootstrap(std::vector const& nodes , boost::function0 f) { +#ifdef TORRENT_DHT_VERBOSE_LOGGING + TORRENT_LOG(node) << "bootrapping: " << nodes.size(); + for (std::vector::const_iterator i = nodes.begin() + , end(nodes.end()); i != end; ++i) + TORRENT_LOG(node) << " " << *i; +#endif std::vector start; start.reserve(nodes.size()); std::copy(nodes.begin(), nodes.end(), std::back_inserter(start)); @@ -254,6 +260,11 @@ namespace , int listen_port, sha1_hash const& ih , boost::function const&, sha1_hash const&)> f) { +#ifdef TORRENT_DHT_VERBOSE_LOGGING + TORRENT_LOG(node) << "announce response [ ih: " << ih + << " p: " << listen_port + << " nodes: " << v.size() << " ]" ; +#endif bool nodes = false; // only store on the first k nodes for (std::vector::const_iterator i = v.begin() @@ -271,6 +282,9 @@ namespace void node_impl::add_router_node(udp::endpoint router) { +#ifdef TORRENT_DHT_VERBOSE_LOGGING + TORRENT_LOG(node) << "adding router node: " << router; +#endif m_table.add_router_node(router); } @@ -288,6 +302,9 @@ void node_impl::add_node(udp::endpoint node) void node_impl::announce(sha1_hash const& info_hash, int listen_port , boost::function const&, sha1_hash const&)> f) { +#ifdef TORRENT_DHT_VERBOSE_LOGGING + TORRENT_LOG(node) << "announcing [ ih: " << info_hash << " p: " << listen_port << " ]" ; +#endif // search for nodes with ids close to id, and then invoke the // get_peers and then announce_peer rpc on them. closest_nodes::initiate(info_hash, m_settings.search_branching diff --git a/libtorrent/src/kademlia/routing_table.cpp b/libtorrent/src/kademlia/routing_table.cpp index c0ba68080..359577613 100644 --- a/libtorrent/src/kademlia/routing_table.cpp +++ b/libtorrent/src/kademlia/routing_table.cpp @@ -436,7 +436,8 @@ void routing_table::find_node(node_id const& target routing_table::iterator routing_table::begin() const { - return iterator(m_buckets.begin(), m_buckets.end()); + // +1 to avoid ourself + return iterator(m_buckets.begin() + 1, m_buckets.end()); } routing_table::iterator routing_table::end() const diff --git a/libtorrent/src/kademlia/traversal_algorithm.cpp b/libtorrent/src/kademlia/traversal_algorithm.cpp index b0d3c5e74..8849b155b 100644 --- a/libtorrent/src/kademlia/traversal_algorithm.cpp +++ b/libtorrent/src/kademlia/traversal_algorithm.cpp @@ -51,7 +51,12 @@ void traversal_algorithm::add_entry(node_id const& id, udp::endpoint addr, unsig { if (m_failed.find(addr) != m_failed.end()) return; - result const entry(id, addr, flags); + result entry(id, addr, flags); + if (entry.id.is_all_zeros()) + { + entry.id = generate_id(); + entry.flags |= result::no_id; + } std::vector::iterator i = std::lower_bound( m_results.begin() @@ -83,6 +88,7 @@ boost::pool<>& traversal_algorithm::allocator() const void traversal_algorithm::traverse(node_id const& id, udp::endpoint addr) { + TORRENT_ASSERT(!id.is_all_zeros()); add_entry(id, addr, 0); } @@ -100,6 +106,7 @@ void traversal_algorithm::failed(node_id const& id, bool prevent_request) { m_invoke_count--; + TORRENT_ASSERT(!id.is_all_zeros()); std::vector::iterator i = std::find_if( m_results.begin() , m_results.end() @@ -119,6 +126,10 @@ void traversal_algorithm::failed(node_id const& id, bool prevent_request) #ifdef TORRENT_DHT_VERBOSE_LOGGING TORRENT_LOG(traversal) << "failed: " << i->id << " " << i->addr; #endif + // don't tell the routing table about + // node ids that we just generated ourself + if ((i->flags & result::no_id) == 0) + m_table.node_failed(id); m_results.erase(i); } if (prevent_request) @@ -126,10 +137,6 @@ void traversal_algorithm::failed(node_id const& id, bool prevent_request) --m_branch_factor; if (m_branch_factor <= 0) m_branch_factor = 1; } - else - { - m_table.node_failed(id); - } add_requests(); if (m_invoke_count == 0) done(); } diff --git a/libtorrent/src/peer_connection.cpp b/libtorrent/src/peer_connection.cpp index dbc6f4e43..38e80c895 100755 --- a/libtorrent/src/peer_connection.cpp +++ b/libtorrent/src/peer_connection.cpp @@ -2402,6 +2402,7 @@ namespace libtorrent if (ret != r.length || m_torrent.expired()) { + if (j.buffer) m_ses.free_disk_buffer(j.buffer); boost::shared_ptr t = m_torrent.lock(); if (!t) { diff --git a/libtorrent/src/session_impl.cpp b/libtorrent/src/session_impl.cpp index af871d6bf..0a6b7176c 100755 --- a/libtorrent/src/session_impl.cpp +++ b/libtorrent/src/session_impl.cpp @@ -240,7 +240,7 @@ namespace detail if (m_ses.m_alerts.should_post(alert::info)) { m_ses.m_alerts.post_alert(torrent_checked_alert( - processing->torrent_ptr->get_handle() + t->torrent_ptr->get_handle() , "torrent finished checking")); } if (t->torrent_ptr->is_seed() && m_ses.m_alerts.should_post(alert::info)) diff --git a/setup.py b/setup.py index 7640ff558..012746fb4 100644 --- a/setup.py +++ b/setup.py @@ -28,7 +28,7 @@ NAME = "deluge" FULLNAME = "Deluge BitTorrent Client" -VERSION = "0.5.8.6" +VERSION = "0.5.8.7" AUTHOR = "Zach Tibbitts, Alon Zakai, Marcos Pinto, Andrew Resch, Alex Dedul" EMAIL = "zach@collegegeek.org, kripkensteiner@gmail.com, marcospinto@dipconsultants.com, alonzakai@gmail.com, rotmer@gmail.com" DESCRIPTION = "A GTK BitTorrent client written in Python and C++" diff --git a/src/common.py b/src/common.py index 77be08a5d..8c2a9757c 100644 --- a/src/common.py +++ b/src/common.py @@ -32,7 +32,7 @@ import os import xdg.BaseDirectory PROGRAM_NAME = "Deluge" -PROGRAM_VERSION = "0.5.8.6" +PROGRAM_VERSION = "0.5.8.7" CLIENT_CODE = "DE" CLIENT_VERSION = "".join(PROGRAM_VERSION.split('.'))+"0"*(4 - len(PROGRAM_VERSION.split('.')))