diff --git a/libtorrent/include/libtorrent/assert.hpp b/libtorrent/include/libtorrent/assert.hpp index 246e3b51b..dd3c6b737 100644 --- a/libtorrent/include/libtorrent/assert.hpp +++ b/libtorrent/include/libtorrent/assert.hpp @@ -41,6 +41,7 @@ TORRENT_EXPORT void assert_fail(const char* expr, int line, char const* file, ch #define TORRENT_ASSERT(x) if (x) {} else assert_fail(#x, __LINE__, __FILE__, __PRETTY_FUNCTION__) #else +#include #define TORRENT_ASSERT(x) assert(x) #endif diff --git a/libtorrent/include/libtorrent/aux_/session_impl.hpp b/libtorrent/include/libtorrent/aux_/session_impl.hpp index cf627c70b..c9b6cb218 100644 --- a/libtorrent/include/libtorrent/aux_/session_impl.hpp +++ b/libtorrent/include/libtorrent/aux_/session_impl.hpp @@ -379,6 +379,7 @@ namespace libtorrent // this pool is used to allocate and recycle send // buffers from. boost::pool<> m_send_buffers; + boost::mutex m_send_buffer_mutex; // the file pool that all storages in this session's // torrents uses. It sets a limit on the number of diff --git a/libtorrent/src/session_impl.cpp b/libtorrent/src/session_impl.cpp index 5eaad1c16..8851f7579 100755 --- a/libtorrent/src/session_impl.cpp +++ b/libtorrent/src/session_impl.cpp @@ -2391,7 +2391,11 @@ namespace detail std::pair session_impl::allocate_buffer(int size) { + TORRENT_ASSERT(size > 0); int num_buffers = (size + send_buffer_size - 1) / send_buffer_size; + TORRENT_ASSERT(num_buffers > 0); + + boost::mutex::scoped_lock l(m_send_buffer_mutex); #ifdef TORRENT_STATS m_buffer_allocations += num_buffers; m_buffer_usage_logger << log_time() << " protocol_buffer: " @@ -2403,8 +2407,12 @@ namespace detail void session_impl::free_buffer(char* buf, int size) { + TORRENT_ASSERT(size > 0); TORRENT_ASSERT(size % send_buffer_size == 0); int num_buffers = size / send_buffer_size; + TORRENT_ASSERT(num_buffers > 0); + + boost::mutex::scoped_lock l(m_send_buffer_mutex); #ifdef TORRENT_STATS m_buffer_allocations -= num_buffers; TORRENT_ASSERT(m_buffer_allocations >= 0); diff --git a/libtorrent/src/torrent.cpp b/libtorrent/src/torrent.cpp index e8c1f2247..7b5da1298 100755 --- a/libtorrent/src/torrent.cpp +++ b/libtorrent/src/torrent.cpp @@ -2147,6 +2147,11 @@ namespace libtorrent throw protocol_error("session is closing"); } + if (int(m_connections.size()) >= m_max_connections) + { + throw protocol_error("reached connection limit"); + } + TORRENT_ASSERT(m_connections.find(p) == m_connections.end()); peer_iterator ci = m_connections.insert(p).first; try diff --git a/src/core.py b/src/core.py index afa4eab16..4366de011 100644 --- a/src/core.py +++ b/src/core.py @@ -877,7 +877,6 @@ Space:") + " " + nice_free) del self.state.torrents[torrent] continue if torrent not in self.unique_IDs.values(): -# print "Adding torrent to core:", torrent.filename, torrent.save_dir, torrent.compact try: unique_ID = deluge_core.add_torrent(torrent.filename, torrent.save_dir, diff --git a/src/interface.py b/src/interface.py index cd8c13ab6..b3f8c2494 100644 --- a/src/interface.py +++ b/src/interface.py @@ -746,7 +746,7 @@ window, please enter your password")) def double_click_folder(self, tree, path, view_column): self.open_folder(view_column) - def open_folder(self, widget): + def open_folder(self, widget, uids=None): if not common.windows_check(): if self.config.get("open_folder_stock"): if self.config.get("file_manager") == common.FileManager.xdg: @@ -763,8 +763,11 @@ window, please enter your password")) else: file_manager = "explorer.exe" - - unique_ids = self.get_selected_torrent_rows() + if not uids: + unique_ids = self.get_selected_torrent_rows() + else: + unique_ids = uids + try: for uid in unique_ids: torrent_path = self.manager.get_torrent_path(uid)