tweaks and lt sync

This commit is contained in:
Marcos Pinto 2007-12-28 23:35:11 +00:00
parent 4156788296
commit eeb2c26002
6 changed files with 21 additions and 4 deletions

View File

@ -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 <cassert>
#define TORRENT_ASSERT(x) assert(x)
#endif

View File

@ -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

View File

@ -2391,7 +2391,11 @@ namespace detail
std::pair<char*, int> 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);

View File

@ -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

View File

@ -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,

View File

@ -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"
if not uids:
unique_ids = self.get_selected_torrent_rows()
else:
unique_ids = uids
unique_ids = self.get_selected_torrent_rows()
try:
for uid in unique_ids:
torrent_path = self.manager.get_torrent_path(uid)