got rid of the last recursive mutexes. abstracted the threading primitives (and switched over to use asio's internal ones).
This commit is contained in:
parent
a5fb1b3455
commit
8a5b7d5d36
|
@ -154,9 +154,9 @@ else (shared)
|
|||
add_library(torrent-rasterbar STATIC ${sources2} ${zlib_sources2})
|
||||
endif (shared)
|
||||
|
||||
FIND_PACKAGE( Boost 1.34 COMPONENTS filesystem thread)
|
||||
FIND_PACKAGE( Boost 1.34 COMPONENTS filesystem)
|
||||
if (NOT Boost_VERSION LESS 103500)
|
||||
FIND_PACKAGE( Boost 1.35 COMPONENTS filesystem thread system)
|
||||
FIND_PACKAGE( Boost 1.35 COMPONENTS filesystem system)
|
||||
endif (NOT Boost_VERSION LESS 103500)
|
||||
include_directories(${Boost_INCLUDE_DIR})
|
||||
target_link_libraries(torrent-rasterbar ${Boost_LIBRARIES})
|
||||
|
|
17
Jamfile
17
Jamfile
|
@ -101,7 +101,6 @@ rule linking ( properties * )
|
|||
if <boost>system in $(properties)
|
||||
{
|
||||
result += <library>boost_filesystem
|
||||
<library>boost_thread
|
||||
<library>boost_system
|
||||
;
|
||||
}
|
||||
|
@ -127,22 +126,10 @@ rule linking ( properties * )
|
|||
result += <library>/boost/filesystem//boost_filesystem/<link>static
|
||||
<library>/boost/system//boost_system/<link>static
|
||||
;
|
||||
|
||||
# if we're building a shared library
|
||||
# we need to link dynamically against the
|
||||
# pthread library
|
||||
if <fpic>on in $(properties) && <target-os>linux in $(properties)
|
||||
{
|
||||
result += <library>/boost/thread//boost_thread/<link>shared ;
|
||||
}
|
||||
else
|
||||
{
|
||||
result += <library>/boost/thread//boost_thread/<link>static ;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result += <library>/boost/thread//boost_thread/<link>shared
|
||||
result +=
|
||||
<library>/boost/filesystem//boost_filesystem/<link>shared
|
||||
<library>/boost/system//boost_system/<link>shared
|
||||
;
|
||||
|
@ -309,11 +296,9 @@ local boost-library-search-path =
|
|||
;
|
||||
|
||||
lib boost_filesystem : : <target-os>darwin <name>boost_filesystem-mt $(boost-library-search-path) ;
|
||||
lib boost_thread : : <target-os>darwin <name>boost_thread-mt $(boost-library-search-path) ;
|
||||
lib boost_system : : <target-os>darwin <name>boost_system-mt $(boost-library-search-path) ;
|
||||
|
||||
lib boost_filesystem : : <name>boost_filesystem ;
|
||||
lib boost_thread : : <name>boost_thread ;
|
||||
lib boost_system : : <name>boost_system ;
|
||||
|
||||
# openssl on linux/bsd/macos etc.
|
||||
|
|
|
@ -42,8 +42,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#pragma warning(push, 1)
|
||||
#endif
|
||||
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <boost/thread/condition.hpp>
|
||||
#include <boost/function.hpp>
|
||||
|
||||
#include <boost/preprocessor/repetition/enum_params_with_a_default.hpp>
|
||||
|
@ -58,6 +56,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/time.hpp"
|
||||
#include "libtorrent/config.hpp"
|
||||
#include "libtorrent/assert.hpp"
|
||||
#include "libtorrent/thread.hpp"
|
||||
#include "libtorrent/socket.hpp" // for io_service
|
||||
|
||||
#ifndef TORRENT_MAX_ALERT_TYPES
|
||||
|
@ -126,7 +125,7 @@ namespace libtorrent {
|
|||
template <class T>
|
||||
bool should_post() const
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_mutex);
|
||||
mutex::scoped_lock lock(m_mutex);
|
||||
if (m_alerts.size() >= m_queue_size_limit) return false;
|
||||
return (m_alert_mask & T::static_category) != 0;
|
||||
}
|
||||
|
@ -135,7 +134,7 @@ namespace libtorrent {
|
|||
|
||||
void set_alert_mask(int m)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_mutex);
|
||||
mutex::scoped_lock lock(m_mutex);
|
||||
m_alert_mask = m;
|
||||
}
|
||||
|
||||
|
@ -146,8 +145,8 @@ namespace libtorrent {
|
|||
|
||||
private:
|
||||
std::queue<alert*> m_alerts;
|
||||
mutable boost::mutex m_mutex;
|
||||
boost::condition m_condition;
|
||||
mutable mutex m_mutex;
|
||||
condition m_condition;
|
||||
int m_alert_mask;
|
||||
size_t m_queue_size_limit;
|
||||
boost::function<void(alert const&)> m_dispatch;
|
||||
|
|
|
@ -51,8 +51,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#endif
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/thread/condition.hpp>
|
||||
#include <boost/pool/object_pool.hpp>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
@ -79,6 +77,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/disk_io_thread.hpp"
|
||||
#include "libtorrent/udp_socket.hpp"
|
||||
#include "libtorrent/assert.hpp"
|
||||
#include "libtorrent/thread.hpp"
|
||||
#include "libtorrent/policy.hpp" // for policy::peer
|
||||
#include "libtorrent/alert.hpp" // for alert_manager
|
||||
#include "libtorrent/deadline_timer.hpp"
|
||||
|
@ -147,7 +146,7 @@ namespace libtorrent
|
|||
!= m_connections.end();
|
||||
}
|
||||
#endif
|
||||
void operator()();
|
||||
void main_thread();
|
||||
|
||||
void open_listen_port();
|
||||
|
||||
|
@ -167,8 +166,7 @@ namespace libtorrent
|
|||
|
||||
// must be locked to access the data
|
||||
// in this struct
|
||||
typedef boost::mutex mutex_t;
|
||||
mutable mutex_t m_mutex;
|
||||
mutable mutex m_mutex;
|
||||
|
||||
boost::weak_ptr<torrent> find_torrent(const sha1_hash& info_hash);
|
||||
peer_id const& get_peer_id() const { return m_peer_id; }
|
||||
|
@ -187,7 +185,7 @@ namespace libtorrent
|
|||
void start_dht(entry const& startup_state);
|
||||
void stop_dht();
|
||||
|
||||
entry dht_state(session_impl::mutex_t::scoped_lock& l) const;
|
||||
entry dht_state(mutex::scoped_lock& l) const;
|
||||
void maybe_update_udp_mapping(int nat, int local_port, int external_port);
|
||||
#endif
|
||||
|
||||
|
@ -367,7 +365,7 @@ namespace libtorrent
|
|||
|
||||
// private:
|
||||
|
||||
void on_dht_state_callback(boost::condition& c
|
||||
void on_dht_state_callback(condition& c
|
||||
, entry& e, bool& done) const;
|
||||
void on_lsd_peer(tcp::endpoint peer, sha1_hash const& ih);
|
||||
void setup_socket_buffers(socket_type& s);
|
||||
|
@ -428,7 +426,7 @@ namespace libtorrent
|
|||
// buffers from.
|
||||
boost::pool<> m_send_buffers;
|
||||
#endif
|
||||
boost::mutex m_send_buffer_mutex;
|
||||
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
|
||||
|
@ -750,7 +748,7 @@ namespace libtorrent
|
|||
size_type m_total_redundant_bytes;
|
||||
|
||||
// the main working thread
|
||||
boost::scoped_ptr<boost::thread> m_thread;
|
||||
boost::scoped_ptr<thread> m_thread;
|
||||
};
|
||||
|
||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
||||
|
|
|
@ -45,6 +45,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/assert.hpp"
|
||||
#include "libtorrent/bandwidth_limit.hpp"
|
||||
#include "libtorrent/bandwidth_queue_entry.hpp"
|
||||
#include "libtorrent/thread.hpp"
|
||||
#include "libtorrent/bandwidth_socket.hpp"
|
||||
#include "libtorrent/time.hpp"
|
||||
|
||||
|
|
|
@ -36,7 +36,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <list>
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include "libtorrent/socket.hpp"
|
||||
#include "libtorrent/error_code.hpp"
|
||||
#include "libtorrent/deadline_timer.hpp"
|
||||
|
@ -45,6 +44,8 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <fstream>
|
||||
#endif
|
||||
|
||||
#include "libtorrent/thread.hpp"
|
||||
|
||||
namespace libtorrent
|
||||
{
|
||||
|
||||
|
@ -72,7 +73,7 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
typedef boost::mutex mutex_t;
|
||||
typedef mutex mutex_t;
|
||||
|
||||
void try_connect(mutex_t::scoped_lock& l);
|
||||
void on_timeout(error_code const& e);
|
||||
|
|
|
@ -39,9 +39,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include "libtorrent/storage.hpp"
|
||||
#include "libtorrent/allocator.hpp"
|
||||
#include <boost/thread/thread.hpp>
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <boost/thread/condition.hpp>
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
|
@ -52,6 +49,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <boost/pool/pool.hpp>
|
||||
#endif
|
||||
#include "libtorrent/session_settings.hpp"
|
||||
#include "libtorrent/thread.hpp"
|
||||
|
||||
namespace libtorrent
|
||||
{
|
||||
|
@ -190,7 +188,7 @@ namespace libtorrent
|
|||
|
||||
#if defined TORRENT_DEBUG || defined TORRENT_DISK_STATS
|
||||
bool is_disk_buffer(char* buffer
|
||||
, boost::mutex::scoped_lock& l) const;
|
||||
, mutex::scoped_lock& l) const;
|
||||
bool is_disk_buffer(char* buffer) const;
|
||||
#endif
|
||||
|
||||
|
@ -228,9 +226,8 @@ namespace libtorrent
|
|||
|
||||
private:
|
||||
|
||||
// this only protects the pool allocator
|
||||
typedef boost::mutex mutex_t;
|
||||
mutable mutex_t m_pool_mutex;
|
||||
mutable mutex m_pool_mutex;
|
||||
|
||||
#ifndef TORRENT_DISABLE_POOL_ALLOCATOR
|
||||
// memory pool for read and write operations
|
||||
// and disk cache
|
||||
|
@ -282,7 +279,7 @@ namespace libtorrent
|
|||
|
||||
cache_status status() const;
|
||||
|
||||
void operator()();
|
||||
void thread_fun();
|
||||
|
||||
#ifdef TORRENT_DEBUG
|
||||
void check_invariant() const;
|
||||
|
@ -312,11 +309,15 @@ namespace libtorrent
|
|||
boost::shared_array<cached_block_entry> blocks;
|
||||
};
|
||||
|
||||
typedef boost::recursive_mutex mutex_t;
|
||||
typedef std::list<cached_piece_entry> cache_t;
|
||||
|
||||
private:
|
||||
|
||||
void add_job(disk_io_job const& j
|
||||
, mutex::scoped_lock& l
|
||||
, boost::function<void(int, disk_io_job const&)> const& f
|
||||
= boost::function<void(int, disk_io_job const&)>());
|
||||
|
||||
bool test_error(disk_io_job& j);
|
||||
void post_callback(boost::function<void(int, disk_io_job const&)> const& handler
|
||||
, disk_io_job const& j, int ret);
|
||||
|
@ -324,39 +325,39 @@ namespace libtorrent
|
|||
// cache operations
|
||||
cache_t::iterator find_cached_piece(
|
||||
cache_t& cache, disk_io_job const& j
|
||||
, mutex_t::scoped_lock& l);
|
||||
, mutex::scoped_lock& l);
|
||||
int copy_from_piece(cache_t::iterator p, bool& hit
|
||||
, disk_io_job const& j, mutex_t::scoped_lock& l);
|
||||
, disk_io_job const& j, mutex::scoped_lock& l);
|
||||
|
||||
// write cache operations
|
||||
enum options_t { dont_flush_write_blocks = 1, ignore_cache_size = 2 };
|
||||
int flush_cache_blocks(mutex_t::scoped_lock& l
|
||||
int flush_cache_blocks(mutex::scoped_lock& l
|
||||
, int blocks, cache_t::iterator ignore
|
||||
, int options = 0);
|
||||
void flush_expired_pieces();
|
||||
int flush_and_remove(cache_t::iterator i, mutex_t::scoped_lock& l);
|
||||
int flush_and_remove(cache_t::iterator i, mutex::scoped_lock& l);
|
||||
int flush_contiguous_blocks(disk_io_thread::cache_t::iterator e
|
||||
, mutex_t::scoped_lock& l, int lower_limit = 0);
|
||||
int flush_range(cache_t::iterator i, int start, int end, mutex_t::scoped_lock& l);
|
||||
, mutex::scoped_lock& l, int lower_limit = 0);
|
||||
int flush_range(cache_t::iterator i, int start, int end, mutex::scoped_lock& l);
|
||||
int cache_block(disk_io_job& j
|
||||
, boost::function<void(int,disk_io_job const&)>& handler
|
||||
, mutex_t::scoped_lock& l);
|
||||
, mutex::scoped_lock& l);
|
||||
|
||||
// read cache operations
|
||||
int clear_oldest_read_piece(int num_blocks, cache_t::iterator ignore
|
||||
, mutex_t::scoped_lock& l);
|
||||
, mutex::scoped_lock& l);
|
||||
int read_into_piece(cached_piece_entry& p, int start_block
|
||||
, int options, int num_blocks, mutex_t::scoped_lock& l);
|
||||
int cache_read_block(disk_io_job const& j, mutex_t::scoped_lock& l);
|
||||
int cache_read_piece(disk_io_job const& j, mutex_t::scoped_lock& l);
|
||||
int free_piece(cached_piece_entry& p, mutex_t::scoped_lock& l);
|
||||
, int options, int num_blocks, mutex::scoped_lock& l);
|
||||
int cache_read_block(disk_io_job const& j, mutex::scoped_lock& l);
|
||||
int cache_read_piece(disk_io_job const& j, mutex::scoped_lock& l);
|
||||
int free_piece(cached_piece_entry& p, mutex::scoped_lock& l);
|
||||
int try_read_from_cache(disk_io_job const& j);
|
||||
int read_piece_from_cache_and_hash(disk_io_job const& j, sha1_hash& h);
|
||||
|
||||
// this mutex only protects m_jobs, m_queue_buffer_size
|
||||
// and m_abort
|
||||
mutable mutex_t m_queue_mutex;
|
||||
boost::condition m_signal;
|
||||
mutable mutex m_queue_mutex;
|
||||
condition m_signal;
|
||||
bool m_abort;
|
||||
bool m_waiting_to_shutdown;
|
||||
std::list<disk_io_job> m_jobs;
|
||||
|
@ -365,7 +366,7 @@ namespace libtorrent
|
|||
ptime m_last_file_check;
|
||||
|
||||
// this protects the piece cache and related members
|
||||
mutable mutex_t m_piece_mutex;
|
||||
mutable mutex m_piece_mutex;
|
||||
// write cache
|
||||
cache_t m_pieces;
|
||||
|
||||
|
@ -398,7 +399,7 @@ namespace libtorrent
|
|||
boost::optional<asio::io_service::work> m_work;
|
||||
|
||||
// thread for performing blocking disk io operations
|
||||
boost::thread m_disk_io_thread;
|
||||
thread m_disk_io_thread;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -39,14 +39,15 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#include <map>
|
||||
#include "libtorrent/file.hpp"
|
||||
#include "libtorrent/time.hpp"
|
||||
#include "libtorrent/thread.hpp"
|
||||
|
||||
namespace libtorrent
|
||||
{
|
||||
|
@ -81,7 +82,7 @@ namespace libtorrent
|
|||
typedef std::map<std::string, lru_file_entry> file_set;
|
||||
|
||||
file_set m_files;
|
||||
boost::mutex m_mutex;
|
||||
mutex m_mutex;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <boost/filesystem/operations.hpp>
|
||||
#include <boost/intrusive_ptr.hpp>
|
||||
#include <boost/detail/atomic_count.hpp>
|
||||
#include <boost/thread/mutex.hpp>
|
||||
|
||||
#include "libtorrent/kademlia/node.hpp"
|
||||
#include "libtorrent/kademlia/node_id.hpp"
|
||||
|
@ -53,6 +52,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/session_status.hpp"
|
||||
#include "libtorrent/udp_socket.hpp"
|
||||
#include "libtorrent/socket.hpp"
|
||||
#include "libtorrent/thread.hpp"
|
||||
#include "libtorrent/deadline_timer.hpp"
|
||||
|
||||
namespace libtorrent
|
||||
|
@ -132,7 +132,7 @@ namespace libtorrent { namespace dht
|
|||
|
||||
// The mutex is used to abort the dht node
|
||||
// it's only used to set m_abort to true
|
||||
typedef boost::mutex mutex_t;
|
||||
typedef mutex mutex_t;
|
||||
mutable mutex_t m_mutex;
|
||||
bool m_abort;
|
||||
|
||||
|
|
|
@ -46,12 +46,12 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <libtorrent/io.hpp>
|
||||
#include <libtorrent/session_settings.hpp>
|
||||
#include <libtorrent/assert.hpp>
|
||||
#include <libtorrent/thread.hpp>
|
||||
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/iterator/transform_iterator.hpp>
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include "libtorrent/socket.hpp"
|
||||
|
@ -278,7 +278,7 @@ protected:
|
|||
int m_max_peers_reply;
|
||||
|
||||
private:
|
||||
typedef boost::mutex mutex_t;
|
||||
typedef libtorrent::mutex mutex_t;
|
||||
mutex_t m_mutex;
|
||||
|
||||
// this list must be destructed after the rpc manager
|
||||
|
|
|
@ -37,6 +37,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <boost/detail/atomic_count.hpp>
|
||||
#include <boost/intrusive_ptr.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <libtorrent/time.hpp>
|
||||
|
||||
namespace libtorrent {
|
||||
namespace dht {
|
||||
|
|
|
@ -50,6 +50,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <libtorrent/session_settings.hpp>
|
||||
#include <libtorrent/size_type.hpp>
|
||||
#include <libtorrent/assert.hpp>
|
||||
#include <libtorrent/time.hpp>
|
||||
|
||||
namespace libtorrent
|
||||
{
|
||||
|
|
|
@ -42,8 +42,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <boost/function.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <boost/thread/condition.hpp>
|
||||
|
||||
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
|
||||
#include <fstream>
|
||||
|
|
|
@ -34,12 +34,12 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#define TORRENT_NATPMP_HPP
|
||||
|
||||
#include "libtorrent/socket.hpp"
|
||||
#include "libtorrent/thread.hpp"
|
||||
#include "libtorrent/error_code.hpp"
|
||||
#include "libtorrent/intrusive_ptr_base.hpp"
|
||||
#include "libtorrent/deadline_timer.hpp"
|
||||
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/thread/mutex.hpp>
|
||||
|
||||
namespace libtorrent
|
||||
{
|
||||
|
@ -70,20 +70,18 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
typedef boost::mutex mutex_t;
|
||||
|
||||
void update_mapping(int i, mutex_t::scoped_lock& l);
|
||||
void send_map_request(int i, mutex_t::scoped_lock& l);
|
||||
void update_mapping(int i, mutex::scoped_lock& l);
|
||||
void send_map_request(int i, mutex::scoped_lock& l);
|
||||
void resend_request(int i, error_code const& e);
|
||||
void on_reply(error_code const& e
|
||||
, std::size_t bytes_transferred);
|
||||
void try_next_mapping(int i, mutex_t::scoped_lock& l);
|
||||
void try_next_mapping(int i, mutex::scoped_lock& l);
|
||||
void update_expiration_timer();
|
||||
void mapping_expired(error_code const& e, int i);
|
||||
void close_impl(mutex_t::scoped_lock& l);
|
||||
void close_impl(mutex::scoped_lock& l);
|
||||
|
||||
void log(char const* msg, mutex_t::scoped_lock& l);
|
||||
void disable(error_code const& ec, mutex_t::scoped_lock& l);
|
||||
void log(char const* msg, mutex::scoped_lock& l);
|
||||
void disable(error_code const& ec, mutex::scoped_lock& l);
|
||||
|
||||
struct mapping_t
|
||||
{
|
||||
|
@ -158,7 +156,7 @@ private:
|
|||
|
||||
bool m_abort;
|
||||
|
||||
mutable mutex_t m_mutex;
|
||||
mutable mutex m_mutex;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -42,7 +42,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include <boost/limits.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
|
|
|
@ -41,7 +41,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/limits.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/intrusive_ptr.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
@ -59,6 +58,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/config.hpp"
|
||||
#include "libtorrent/file.hpp"
|
||||
#include "libtorrent/disk_buffer_holder.hpp"
|
||||
#include "libtorrent/thread.hpp"
|
||||
|
||||
namespace libtorrent
|
||||
{
|
||||
|
@ -405,7 +405,7 @@ namespace libtorrent
|
|||
|
||||
fs::path m_save_path;
|
||||
|
||||
mutable boost::recursive_mutex m_mutex;
|
||||
mutable mutex m_mutex;
|
||||
|
||||
enum {
|
||||
// the default initial state
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
|
||||
Copyright (c) 2009, Arvid Norberg
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the author nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef TORRENT_THREAD_HPP_INCLUDED
|
||||
#define TORRENT_THREAD_HPP_INCLUDED
|
||||
|
||||
#include "libtorrent/config.hpp"
|
||||
#include <boost/asio/detail/thread.hpp>
|
||||
#include <boost/asio/detail/mutex.hpp>
|
||||
#include <boost/asio/detail/event.hpp>
|
||||
|
||||
namespace libtorrent
|
||||
{
|
||||
typedef boost::asio::detail::thread thread;
|
||||
typedef boost::asio::detail::mutex mutex;
|
||||
typedef boost::asio::detail::event condition;
|
||||
inline void sleep(int milliseconds)
|
||||
{
|
||||
#if defined TORRENT_WINDOWS || defined TORRENT_CYGWIN
|
||||
Sleep(milliseconds);
|
||||
#else
|
||||
usleep(milliseconds * 1000);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -154,7 +154,7 @@ namespace libtorrent
|
|||
void on_force_recheck(int ret, disk_io_job const& j);
|
||||
void on_piece_checked(int ret, disk_io_job const& j);
|
||||
void files_checked_lock();
|
||||
void files_checked(aux::session_impl::mutex_t::scoped_lock const&);
|
||||
void files_checked(mutex::scoped_lock const&);
|
||||
void start_checking();
|
||||
|
||||
void start_announcing();
|
||||
|
|
|
@ -46,8 +46,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <boost/cstdint.hpp>
|
||||
#include <boost/weak_ptr.hpp>
|
||||
#include <boost/intrusive_ptr.hpp>
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <boost/thread/recursive_mutex.hpp>
|
||||
#include <boost/tuple/tuple.hpp>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
@ -180,7 +178,7 @@ namespace libtorrent
|
|||
int m_completion_timeout;
|
||||
int m_read_timeout;
|
||||
|
||||
typedef boost::mutex mutex_t;
|
||||
typedef mutex mutex_t;
|
||||
mutable mutex_t m_mutex;
|
||||
bool m_abort;
|
||||
};
|
||||
|
@ -242,7 +240,7 @@ namespace libtorrent
|
|||
|
||||
private:
|
||||
|
||||
typedef boost::recursive_mutex mutex_t;
|
||||
typedef mutex mutex_t;
|
||||
mutable mutex_t m_mutex;
|
||||
|
||||
typedef std::list<boost::intrusive_ptr<tracker_connection> >
|
||||
|
|
|
@ -37,11 +37,11 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/error_code.hpp"
|
||||
#include "libtorrent/session_settings.hpp"
|
||||
#include "libtorrent/buffer.hpp"
|
||||
#include "libtorrent/thread.hpp"
|
||||
#include "libtorrent/deadline_timer.hpp"
|
||||
|
||||
#include <vector>
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/thread/mutex.hpp>
|
||||
|
||||
namespace libtorrent
|
||||
{
|
||||
|
@ -97,8 +97,7 @@ namespace libtorrent
|
|||
void wrap(udp::endpoint const& ep, char const* p, int len, error_code& ec);
|
||||
void unwrap(error_code const& e, char const* buf, int size);
|
||||
|
||||
typedef boost::mutex mutex_t;
|
||||
mutable mutex_t m_mutex;
|
||||
mutable mutex m_mutex;
|
||||
|
||||
udp::socket m_ipv4_sock;
|
||||
udp::endpoint m_v4_ep;
|
||||
|
|
|
@ -39,13 +39,12 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/http_connection.hpp"
|
||||
#include "libtorrent/connection_queue.hpp"
|
||||
#include "libtorrent/intrusive_ptr_base.hpp"
|
||||
#include "libtorrent/thread.hpp"
|
||||
#include "libtorrent/deadline_timer.hpp"
|
||||
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <boost/thread/condition.hpp>
|
||||
#include <set>
|
||||
|
||||
|
||||
|
@ -119,15 +118,13 @@ public:
|
|||
|
||||
std::string router_model()
|
||||
{
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
return m_model;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
typedef boost::mutex mutex_t;
|
||||
|
||||
void discover_device_impl(mutex_t::scoped_lock& l);
|
||||
void discover_device_impl(mutex::scoped_lock& l);
|
||||
static address_v4 upnp_multicast_address;
|
||||
static udp::endpoint upnp_multicast_endpoint;
|
||||
|
||||
|
@ -142,8 +139,8 @@ private:
|
|||
, std::size_t bytes_transferred);
|
||||
|
||||
struct rootdevice;
|
||||
void next(rootdevice& d, int i, mutex_t::scoped_lock& l);
|
||||
void update_map(rootdevice& d, int i, mutex_t::scoped_lock& l);
|
||||
void next(rootdevice& d, int i, mutex::scoped_lock& l);
|
||||
void update_map(rootdevice& d, int i, mutex::scoped_lock& l);
|
||||
|
||||
|
||||
void on_upnp_xml(error_code const& e
|
||||
|
@ -157,14 +154,14 @@ private:
|
|||
, int mapping, http_connection& c);
|
||||
void on_expire(error_code const& e);
|
||||
|
||||
void disable(error_code const& ec, mutex_t::scoped_lock& l);
|
||||
void return_error(int mapping, int code, mutex_t::scoped_lock& l);
|
||||
void log(char const* msg, mutex_t::scoped_lock& l);
|
||||
void disable(error_code const& ec, mutex::scoped_lock& l);
|
||||
void return_error(int mapping, int code, mutex::scoped_lock& l);
|
||||
void log(char const* msg, mutex::scoped_lock& l);
|
||||
|
||||
void delete_port_mapping(rootdevice& d, int i);
|
||||
void create_port_mapping(http_connection& c, rootdevice& d, int i);
|
||||
void post(upnp::rootdevice const& d, char const* soap
|
||||
, char const* soap_action, mutex_t::scoped_lock& l);
|
||||
, char const* soap_action, mutex::scoped_lock& l);
|
||||
|
||||
int num_mappings() const { return int(m_mappings.size()); }
|
||||
|
||||
|
@ -312,7 +309,7 @@ private:
|
|||
|
||||
connection_queue& m_cc;
|
||||
|
||||
mutex_t m_mutex;
|
||||
mutex m_mutex;
|
||||
|
||||
std::string m_model;
|
||||
};
|
||||
|
|
|
@ -33,15 +33,15 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef TORRENT_UTF8_HPP_INCLUDED
|
||||
#define TORRENT_UTF8_HPP_INCLUDED
|
||||
|
||||
#ifndef BOOST_FILESYSTEM_NARROW_ONLY
|
||||
#if !defined BOOST_FILESYSTEM_NARROW_ONLY && !defined BOOST_NO_STD_WSTRING
|
||||
|
||||
#include <string>
|
||||
#include <cwchar>
|
||||
|
||||
#include "libtorrent/ConvertUTF.h"
|
||||
|
||||
namespace libtorrent
|
||||
{
|
||||
|
||||
inline int utf8_wchar(const std::string &utf8, std::wstring &wide)
|
||||
{
|
||||
// allocate space for worst-case
|
||||
|
@ -100,7 +100,7 @@ namespace libtorrent
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif // !FILESYSTEM_NARROW_ONLY && !BOOST_NO_STD_WSTRING
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -33,7 +33,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/pch.hpp"
|
||||
|
||||
#include "libtorrent/alert.hpp"
|
||||
#include <boost/thread/xtime.hpp>
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
|
@ -60,33 +59,34 @@ namespace libtorrent {
|
|||
|
||||
alert const* alert_manager::wait_for_alert(time_duration max_wait)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_mutex);
|
||||
mutex::scoped_lock lock(m_mutex);
|
||||
|
||||
if (!m_alerts.empty()) return m_alerts.front();
|
||||
|
||||
int secs = total_seconds(max_wait);
|
||||
max_wait -= seconds(secs);
|
||||
boost::xtime xt;
|
||||
boost::xtime_get(&xt, boost::TIME_UTC);
|
||||
xt.sec += secs;
|
||||
boost::int64_t nsec = xt.nsec + total_microseconds(max_wait) * 1000;
|
||||
if (nsec > 1000000000)
|
||||
{
|
||||
nsec -= 1000000000;
|
||||
xt.sec += 1;
|
||||
}
|
||||
xt.nsec = boost::xtime::xtime_nsec_t(nsec);
|
||||
// system_time end = get_system_time()
|
||||
// + boost::posix_time::microseconds(total_microseconds(max_wait));
|
||||
|
||||
// apparently this call can be interrupted
|
||||
// prematurely if there are other signals
|
||||
while (m_condition.timed_wait(lock, xt))
|
||||
if (!m_alerts.empty()) return m_alerts.front();
|
||||
// while (m_condition.timed_wait(lock, end))
|
||||
// if (!m_alerts.empty()) return m_alerts.front();
|
||||
|
||||
return 0;
|
||||
ptime start = time_now_hires();
|
||||
|
||||
// TODO: change this to use an asio timer instead
|
||||
while (m_alerts.empty())
|
||||
{
|
||||
lock.unlock();
|
||||
sleep(50);
|
||||
lock.lock();
|
||||
if (time_now_hires() - start >= max_wait) return 0;
|
||||
}
|
||||
return m_alerts.front();
|
||||
}
|
||||
|
||||
void alert_manager::set_dispatch_function(boost::function<void(alert const&)> const& fun)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_mutex);
|
||||
mutex::scoped_lock lock(m_mutex);
|
||||
|
||||
m_dispatch = fun;
|
||||
|
||||
|
@ -111,7 +111,7 @@ namespace libtorrent {
|
|||
|
||||
void alert_manager::post_alert(const alert& alert_)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_mutex);
|
||||
mutex::scoped_lock lock(m_mutex);
|
||||
|
||||
if (m_dispatch)
|
||||
{
|
||||
|
@ -122,12 +122,13 @@ namespace libtorrent {
|
|||
|
||||
if (m_alerts.size() >= m_queue_size_limit) return;
|
||||
m_alerts.push(alert_.clone().release());
|
||||
m_condition.notify_all();
|
||||
m_condition.signal(lock);
|
||||
m_condition.clear(lock);
|
||||
}
|
||||
|
||||
std::auto_ptr<alert> alert_manager::get()
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_mutex);
|
||||
mutex::scoped_lock lock(m_mutex);
|
||||
|
||||
TORRENT_ASSERT(!m_alerts.empty());
|
||||
|
||||
|
@ -138,14 +139,14 @@ namespace libtorrent {
|
|||
|
||||
bool alert_manager::pending() const
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_mutex);
|
||||
mutex::scoped_lock lock(m_mutex);
|
||||
|
||||
return !m_alerts.empty();
|
||||
}
|
||||
|
||||
size_t alert_manager::set_alert_queue_size_limit(size_t queue_size_limit_)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_mutex);
|
||||
mutex::scoped_lock lock(m_mutex);
|
||||
|
||||
std::swap(m_queue_size_limit, queue_size_limit_);
|
||||
return queue_size_limit_;
|
||||
|
|
|
@ -174,10 +174,6 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
#if BOOST_VERSION >= 103700
|
||||
TORRENT_ASSERT(l.owns_lock());
|
||||
#endif
|
||||
|
||||
#ifdef TORRENT_CONNECTION_LOGGING
|
||||
m_log << log_time() << " " << free_slots() << std::endl;
|
||||
#endif
|
||||
|
|
|
@ -84,7 +84,7 @@ namespace libtorrent
|
|||
|
||||
#if defined TORRENT_DEBUG || defined TORRENT_DISK_STATS
|
||||
bool disk_buffer_pool::is_disk_buffer(char* buffer
|
||||
,boost::mutex::scoped_lock& l) const
|
||||
, mutex::scoped_lock& l) const
|
||||
{
|
||||
TORRENT_ASSERT(m_magic == 0x1337);
|
||||
#ifdef TORRENT_DISK_STATS
|
||||
|
@ -100,14 +100,14 @@ namespace libtorrent
|
|||
|
||||
bool disk_buffer_pool::is_disk_buffer(char* buffer) const
|
||||
{
|
||||
mutex_t::scoped_lock l(m_pool_mutex);
|
||||
mutex::scoped_lock l(m_pool_mutex);
|
||||
return is_disk_buffer(buffer, l);
|
||||
}
|
||||
#endif
|
||||
|
||||
char* disk_buffer_pool::allocate_buffer(char const* category)
|
||||
{
|
||||
mutex_t::scoped_lock l(m_pool_mutex);
|
||||
mutex::scoped_lock l(m_pool_mutex);
|
||||
TORRENT_ASSERT(m_magic == 0x1337);
|
||||
#ifdef TORRENT_DISABLE_POOL_ALLOCATOR
|
||||
char* ret = page_aligned_allocator::malloc(m_block_size);
|
||||
|
@ -142,7 +142,7 @@ namespace libtorrent
|
|||
#ifdef TORRENT_DISK_STATS
|
||||
void disk_buffer_pool::rename_buffer(char* buf, char const* category)
|
||||
{
|
||||
mutex_t::scoped_lock l(m_pool_mutex);
|
||||
mutex::scoped_lock l(m_pool_mutex);
|
||||
TORRENT_ASSERT(is_disk_buffer(buf, l));
|
||||
TORRENT_ASSERT(m_categories.find(m_buf_to_category[buf])
|
||||
!= m_categories.end());
|
||||
|
@ -161,7 +161,7 @@ namespace libtorrent
|
|||
void disk_buffer_pool::free_buffer(char* buf)
|
||||
{
|
||||
TORRENT_ASSERT(buf);
|
||||
mutex_t::scoped_lock l(m_pool_mutex);
|
||||
mutex::scoped_lock l(m_pool_mutex);
|
||||
TORRENT_ASSERT(m_magic == 0x1337);
|
||||
TORRENT_ASSERT(is_disk_buffer(buf, l));
|
||||
#if defined TORRENT_DISK_STATS || defined TORRENT_STATS
|
||||
|
@ -195,7 +195,7 @@ namespace libtorrent
|
|||
|
||||
char* disk_buffer_pool::allocate_buffers(int num_blocks, char const* category)
|
||||
{
|
||||
mutex_t::scoped_lock l(m_pool_mutex);
|
||||
mutex::scoped_lock l(m_pool_mutex);
|
||||
TORRENT_ASSERT(m_magic == 0x1337);
|
||||
#ifdef TORRENT_DISABLE_POOL_ALLOCATOR
|
||||
char* ret = page_aligned_allocator::malloc(m_block_size * num_blocks);
|
||||
|
@ -230,7 +230,7 @@ namespace libtorrent
|
|||
{
|
||||
TORRENT_ASSERT(buf);
|
||||
TORRENT_ASSERT(num_blocks >= 1);
|
||||
mutex_t::scoped_lock l(m_pool_mutex);
|
||||
mutex::scoped_lock l(m_pool_mutex);
|
||||
TORRENT_ASSERT(m_magic == 0x1337);
|
||||
TORRENT_ASSERT(is_disk_buffer(buf, l));
|
||||
#if defined TORRENT_DISK_STATS || defined TORRENT_STATS
|
||||
|
@ -266,7 +266,7 @@ namespace libtorrent
|
|||
{
|
||||
TORRENT_ASSERT(m_magic == 0x1337);
|
||||
#ifndef TORRENT_DISABLE_POOL_ALLOCATOR
|
||||
mutex_t::scoped_lock l(m_pool_mutex);
|
||||
mutex::scoped_lock l(m_pool_mutex);
|
||||
m_pool.release_memory();
|
||||
#endif
|
||||
}
|
||||
|
@ -285,7 +285,7 @@ namespace libtorrent
|
|||
, m_ios(ios)
|
||||
, m_queue_callback(queue_callback)
|
||||
, m_work(io_service::work(m_ios))
|
||||
, m_disk_io_thread(boost::ref(*this))
|
||||
, m_disk_io_thread(boost::bind(&disk_io_thread::thread_fun, this))
|
||||
{
|
||||
#ifdef TORRENT_DISK_STATS
|
||||
m_log.open("disk_io_thread.log", std::ios::trunc);
|
||||
|
@ -299,12 +299,12 @@ namespace libtorrent
|
|||
|
||||
void disk_io_thread::join()
|
||||
{
|
||||
mutex_t::scoped_lock l(m_queue_mutex);
|
||||
mutex::scoped_lock l(m_queue_mutex);
|
||||
disk_io_job j;
|
||||
m_waiting_to_shutdown = true;
|
||||
j.action = disk_io_job::abort_thread;
|
||||
m_jobs.insert(m_jobs.begin(), j);
|
||||
m_signal.notify_all();
|
||||
m_signal.signal(l);
|
||||
l.unlock();
|
||||
|
||||
m_disk_io_thread.join();
|
||||
|
@ -315,7 +315,7 @@ namespace libtorrent
|
|||
|
||||
void disk_io_thread::get_cache_info(sha1_hash const& ih, std::vector<cached_piece_info>& ret) const
|
||||
{
|
||||
mutex_t::scoped_lock l(m_piece_mutex);
|
||||
mutex::scoped_lock l(m_piece_mutex);
|
||||
ret.clear();
|
||||
ret.reserve(m_pieces.size());
|
||||
for (cache_t::const_iterator i = m_pieces.begin()
|
||||
|
@ -352,7 +352,7 @@ namespace libtorrent
|
|||
|
||||
cache_status disk_io_thread::status() const
|
||||
{
|
||||
mutex_t::scoped_lock l(m_piece_mutex);
|
||||
mutex::scoped_lock l(m_piece_mutex);
|
||||
m_cache_stats.total_used_buffers = in_use();
|
||||
m_cache_stats.queued_bytes = m_queue_buffer_size;
|
||||
return m_cache_stats;
|
||||
|
@ -361,7 +361,7 @@ namespace libtorrent
|
|||
// aborts read operations
|
||||
void disk_io_thread::stop(boost::intrusive_ptr<piece_manager> s)
|
||||
{
|
||||
mutex_t::scoped_lock l(m_queue_mutex);
|
||||
mutex::scoped_lock l(m_queue_mutex);
|
||||
// read jobs are aborted, write and move jobs are syncronized
|
||||
for (std::list<disk_io_job>::iterator i = m_jobs.begin();
|
||||
i != m_jobs.end();)
|
||||
|
@ -388,7 +388,7 @@ namespace libtorrent
|
|||
disk_io_job j;
|
||||
j.action = disk_io_job::abort_torrent;
|
||||
j.storage = s;
|
||||
add_job(j);
|
||||
add_job(j, l);
|
||||
}
|
||||
|
||||
bool range_overlap(int start1, int length1, int start2, int length2)
|
||||
|
@ -420,7 +420,7 @@ namespace libtorrent
|
|||
|
||||
disk_io_thread::cache_t::iterator disk_io_thread::find_cached_piece(
|
||||
disk_io_thread::cache_t& cache
|
||||
, disk_io_job const& j, mutex_t::scoped_lock& l)
|
||||
, disk_io_job const& j, mutex::scoped_lock& l)
|
||||
{
|
||||
for (cache_t::iterator i = cache.begin()
|
||||
, end(cache.end()); i != end; ++i)
|
||||
|
@ -435,7 +435,7 @@ namespace libtorrent
|
|||
{
|
||||
ptime now = time_now();
|
||||
|
||||
mutex_t::scoped_lock l(m_piece_mutex);
|
||||
mutex::scoped_lock l(m_piece_mutex);
|
||||
|
||||
INVARIANT_CHECK;
|
||||
// flush write cache
|
||||
|
@ -467,7 +467,7 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
// returns the number of blocks that were freed
|
||||
int disk_io_thread::free_piece(cached_piece_entry& p, mutex_t::scoped_lock& l)
|
||||
int disk_io_thread::free_piece(cached_piece_entry& p, mutex::scoped_lock& l)
|
||||
{
|
||||
int piece_size = p.storage->info()->piece_size(p.piece);
|
||||
int blocks_in_piece = (piece_size + m_block_size - 1) / m_block_size;
|
||||
|
@ -490,7 +490,7 @@ namespace libtorrent
|
|||
int disk_io_thread::clear_oldest_read_piece(
|
||||
int num_blocks
|
||||
, cache_t::iterator ignore
|
||||
, mutex_t::scoped_lock& l)
|
||||
, mutex::scoped_lock& l)
|
||||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
|
@ -564,7 +564,7 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
int disk_io_thread::flush_contiguous_blocks(disk_io_thread::cache_t::iterator e
|
||||
, mutex_t::scoped_lock& l, int lower_limit)
|
||||
, mutex::scoped_lock& l, int lower_limit)
|
||||
{
|
||||
// first find the largest range of contiguous blocks
|
||||
int len = 0;
|
||||
|
@ -600,7 +600,7 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
// flushes 'blocks' blocks from the cache
|
||||
int disk_io_thread::flush_cache_blocks(mutex_t::scoped_lock& l
|
||||
int disk_io_thread::flush_cache_blocks(mutex::scoped_lock& l
|
||||
, int blocks, cache_t::iterator ignore, int options)
|
||||
{
|
||||
// first look if there are any read cache entries that can
|
||||
|
@ -647,7 +647,7 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
int disk_io_thread::flush_and_remove(disk_io_thread::cache_t::iterator e
|
||||
, mutex_t::scoped_lock& l)
|
||||
, mutex::scoped_lock& l)
|
||||
{
|
||||
int ret = flush_range(e, 0, INT_MAX, l);
|
||||
m_pieces.erase(e);
|
||||
|
@ -655,7 +655,7 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
int disk_io_thread::flush_range(disk_io_thread::cache_t::iterator e
|
||||
, int start, int end, mutex_t::scoped_lock& l)
|
||||
, int start, int end, mutex::scoped_lock& l)
|
||||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
|
@ -761,7 +761,7 @@ namespace libtorrent
|
|||
// returns -1 on failure
|
||||
int disk_io_thread::cache_block(disk_io_job& j
|
||||
, boost::function<void(int,disk_io_job const&)>& handler
|
||||
, mutex_t::scoped_lock& l)
|
||||
, mutex::scoped_lock& l)
|
||||
{
|
||||
INVARIANT_CHECK;
|
||||
TORRENT_ASSERT(find_cached_piece(m_pieces, j, l) == m_pieces.end());
|
||||
|
@ -796,7 +796,7 @@ namespace libtorrent
|
|||
// fills a piece with data from disk, returns the total number of bytes
|
||||
// read or -1 if there was an error
|
||||
int disk_io_thread::read_into_piece(cached_piece_entry& p, int start_block
|
||||
, int options, int num_blocks, mutex_t::scoped_lock& l)
|
||||
, int options, int num_blocks, mutex::scoped_lock& l)
|
||||
{
|
||||
int piece_size = p.storage->info()->piece_size(p.piece);
|
||||
int blocks_in_piece = (piece_size + m_block_size - 1) / m_block_size;
|
||||
|
@ -904,7 +904,7 @@ namespace libtorrent
|
|||
// piece regardless of the offset in j
|
||||
// this is used for seed-mode, where we need to read the entire piece to calculate
|
||||
// the hash
|
||||
int disk_io_thread::cache_read_piece(disk_io_job const& j, mutex_t::scoped_lock& l)
|
||||
int disk_io_thread::cache_read_piece(disk_io_job const& j, mutex::scoped_lock& l)
|
||||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
|
@ -933,7 +933,7 @@ namespace libtorrent
|
|||
|
||||
// returns -1 on read error, -2 if there isn't any space in the cache
|
||||
// or the number of bytes read
|
||||
int disk_io_thread::cache_read_block(disk_io_job const& j, mutex_t::scoped_lock& l)
|
||||
int disk_io_thread::cache_read_block(disk_io_job const& j, mutex::scoped_lock& l)
|
||||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
|
@ -1041,7 +1041,7 @@ namespace libtorrent
|
|||
{
|
||||
TORRENT_ASSERT(j.buffer);
|
||||
|
||||
mutex_t::scoped_lock l(m_piece_mutex);
|
||||
mutex::scoped_lock l(m_piece_mutex);
|
||||
|
||||
cache_t::iterator p
|
||||
= find_cached_piece(m_read_pieces, j, l);
|
||||
|
@ -1103,7 +1103,7 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
int disk_io_thread::copy_from_piece(cache_t::iterator p, bool& hit
|
||||
, disk_io_job const& j, mutex_t::scoped_lock& l)
|
||||
, disk_io_job const& j, mutex::scoped_lock& l)
|
||||
{
|
||||
TORRENT_ASSERT(j.buffer);
|
||||
|
||||
|
@ -1165,7 +1165,7 @@ namespace libtorrent
|
|||
{
|
||||
TORRENT_ASSERT(j.buffer);
|
||||
|
||||
mutex_t::scoped_lock l(m_piece_mutex);
|
||||
mutex::scoped_lock l(m_piece_mutex);
|
||||
if (!m_settings.use_read_cache) return -2;
|
||||
|
||||
cache_t::iterator p
|
||||
|
@ -1202,10 +1202,22 @@ namespace libtorrent
|
|||
|
||||
size_type disk_io_thread::queue_buffer_size() const
|
||||
{
|
||||
mutex_t::scoped_lock l(m_queue_mutex);
|
||||
mutex::scoped_lock l(m_queue_mutex);
|
||||
return m_queue_buffer_size;
|
||||
}
|
||||
|
||||
void disk_io_thread::add_job(disk_io_job const& j
|
||||
, mutex::scoped_lock& l
|
||||
, boost::function<void(int, disk_io_job const&)> const& f)
|
||||
{
|
||||
m_jobs.push_back(j);
|
||||
m_jobs.back().callback.swap(const_cast<boost::function<void(int, disk_io_job const&)>&>(f));
|
||||
|
||||
if (j.action == disk_io_job::write)
|
||||
m_queue_buffer_size += j.buffer_size;
|
||||
m_signal.signal(l);
|
||||
}
|
||||
|
||||
void disk_io_thread::add_job(disk_io_job const& j
|
||||
, boost::function<void(int, disk_io_job const&)> const& f)
|
||||
{
|
||||
|
@ -1215,56 +1227,8 @@ namespace libtorrent
|
|||
|| j.action == disk_io_job::abort_thread
|
||||
|| j.action == disk_io_job::update_settings);
|
||||
TORRENT_ASSERT(j.buffer_size <= m_block_size);
|
||||
mutex_t::scoped_lock l(m_queue_mutex);
|
||||
|
||||
std::list<disk_io_job>::reverse_iterator i = m_jobs.rbegin();
|
||||
if (j.action == disk_io_job::read)
|
||||
{
|
||||
// when we're reading, we may not skip
|
||||
// ahead of any write operation that overlaps
|
||||
// the region we're reading
|
||||
for (; i != m_jobs.rend(); i++)
|
||||
{
|
||||
// if *i should come before j, stop
|
||||
// and insert j before i
|
||||
if (*i < j) break;
|
||||
// if we come across a write operation that
|
||||
// overlaps the region we're reading, we need
|
||||
// to stop
|
||||
if (i->action == disk_io_job::write
|
||||
&& i->storage == j.storage
|
||||
&& i->piece == j.piece
|
||||
&& range_overlap(i->offset, i->buffer_size
|
||||
, j.offset, j.buffer_size))
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (j.action == disk_io_job::write)
|
||||
{
|
||||
for (; i != m_jobs.rend(); ++i)
|
||||
{
|
||||
if (*i < j)
|
||||
{
|
||||
if (i != m_jobs.rbegin()
|
||||
&& i.base()->storage.get() != j.storage.get())
|
||||
i = m_jobs.rbegin();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if we are placed in front of all other jobs, put it on the back of
|
||||
// the queue, to sweep the disk in the same direction, and to avoid
|
||||
// starvation. The exception is if the priority is higher than the
|
||||
// job at the front of the queue
|
||||
if (i == m_jobs.rend() && (m_jobs.empty() || j.priority <= m_jobs.back().priority))
|
||||
i = m_jobs.rbegin();
|
||||
|
||||
std::list<disk_io_job>::iterator k = m_jobs.insert(i.base(), j);
|
||||
k->callback.swap(const_cast<boost::function<void(int, disk_io_job const&)>&>(f));
|
||||
if (j.action == disk_io_job::write)
|
||||
m_queue_buffer_size += j.buffer_size;
|
||||
m_signal.notify_all();
|
||||
mutex::scoped_lock l(m_queue_mutex);
|
||||
add_job(j, l, f);
|
||||
}
|
||||
|
||||
bool disk_io_thread::test_error(disk_io_job& j)
|
||||
|
@ -1278,8 +1242,7 @@ namespace libtorrent
|
|||
j.error = ec;
|
||||
j.error_file = j.storage->error_file();
|
||||
#ifdef TORRENT_DEBUG
|
||||
std::cout << "ERROR: '" << ec.message() << " in "
|
||||
<< j.error_file << std::endl;
|
||||
printf("ERROR: '%s' in %s\n", ec.message().c_str(), j.error_file.c_str());
|
||||
#endif
|
||||
j.storage->clear_error();
|
||||
return true;
|
||||
|
@ -1340,7 +1303,7 @@ namespace libtorrent
|
|||
return action_flags[j.action] & buffer_operation;
|
||||
}
|
||||
|
||||
void disk_io_thread::operator()()
|
||||
void disk_io_thread::thread_fun()
|
||||
{
|
||||
size_type elevator_position = 0;
|
||||
int elevator_direction = 1;
|
||||
|
@ -1350,7 +1313,7 @@ namespace libtorrent
|
|||
#ifdef TORRENT_DISK_STATS
|
||||
m_log << log_time() << " idle" << std::endl;
|
||||
#endif
|
||||
mutex_t::scoped_lock jl(m_queue_mutex);
|
||||
mutex::scoped_lock jl(m_queue_mutex);
|
||||
|
||||
while (m_jobs.empty() && !m_abort)
|
||||
{
|
||||
|
@ -1359,13 +1322,14 @@ namespace libtorrent
|
|||
// if (!m_signal.timed_wait(jl, boost::posix_time::seconds(1)))
|
||||
// flush_expired_pieces();
|
||||
m_signal.wait(jl);
|
||||
m_signal.clear(jl);
|
||||
}
|
||||
|
||||
if (m_abort && m_jobs.empty())
|
||||
{
|
||||
jl.unlock();
|
||||
|
||||
mutex_t::scoped_lock l(m_piece_mutex);
|
||||
mutex::scoped_lock l(m_piece_mutex);
|
||||
// flush all disk caches
|
||||
for (cache_t::iterator i = m_pieces.begin()
|
||||
, end(m_pieces.end()); i != end; ++i)
|
||||
|
@ -1521,7 +1485,7 @@ namespace libtorrent
|
|||
#ifdef TORRENT_DISK_STATS
|
||||
m_log << log_time() << " abort_torrent " << std::endl;
|
||||
#endif
|
||||
mutex_t::scoped_lock jl(m_queue_mutex);
|
||||
mutex::scoped_lock jl(m_queue_mutex);
|
||||
for (std::list<disk_io_job>::iterator i = m_jobs.begin();
|
||||
i != m_jobs.end();)
|
||||
{
|
||||
|
@ -1545,7 +1509,7 @@ namespace libtorrent
|
|||
#ifdef TORRENT_DISK_STATS
|
||||
m_log << log_time() << " abort_thread " << std::endl;
|
||||
#endif
|
||||
mutex_t::scoped_lock jl(m_queue_mutex);
|
||||
mutex::scoped_lock jl(m_queue_mutex);
|
||||
|
||||
for (std::list<disk_io_job>::iterator i = m_jobs.begin();
|
||||
i != m_jobs.end();)
|
||||
|
@ -1702,7 +1666,7 @@ namespace libtorrent
|
|||
#ifdef TORRENT_DISK_STATS
|
||||
m_log << log_time() << " write " << j.buffer_size << std::endl;
|
||||
#endif
|
||||
mutex_t::scoped_lock l(m_piece_mutex);
|
||||
mutex::scoped_lock l(m_piece_mutex);
|
||||
INVARIANT_CHECK;
|
||||
|
||||
if (in_use() >= m_settings.cache_size)
|
||||
|
@ -1762,7 +1726,7 @@ namespace libtorrent
|
|||
#ifdef TORRENT_DISK_STATS
|
||||
m_log << log_time() << " hash" << std::endl;
|
||||
#endif
|
||||
mutex_t::scoped_lock l(m_piece_mutex);
|
||||
mutex::scoped_lock l(m_piece_mutex);
|
||||
INVARIANT_CHECK;
|
||||
|
||||
cache_t::iterator i
|
||||
|
@ -1817,7 +1781,7 @@ namespace libtorrent
|
|||
#endif
|
||||
TORRENT_ASSERT(j.buffer == 0);
|
||||
|
||||
mutex_t::scoped_lock l(m_piece_mutex);
|
||||
mutex::scoped_lock l(m_piece_mutex);
|
||||
INVARIANT_CHECK;
|
||||
|
||||
for (cache_t::iterator i = m_pieces.begin(); i != m_pieces.end();)
|
||||
|
@ -1846,7 +1810,7 @@ namespace libtorrent
|
|||
#endif
|
||||
TORRENT_ASSERT(j.buffer == 0);
|
||||
|
||||
mutex_t::scoped_lock l(m_piece_mutex);
|
||||
mutex::scoped_lock l(m_piece_mutex);
|
||||
INVARIANT_CHECK;
|
||||
|
||||
for (cache_t::iterator i = m_read_pieces.begin();
|
||||
|
@ -1874,7 +1838,7 @@ namespace libtorrent
|
|||
#endif
|
||||
TORRENT_ASSERT(j.buffer == 0);
|
||||
|
||||
mutex_t::scoped_lock l(m_piece_mutex);
|
||||
mutex::scoped_lock l(m_piece_mutex);
|
||||
INVARIANT_CHECK;
|
||||
|
||||
cache_t::iterator i = std::remove_if(
|
||||
|
@ -1929,8 +1893,7 @@ namespace libtorrent
|
|||
if (sleep_time < 0) sleep_time = 0;
|
||||
TORRENT_ASSERT(sleep_time < 5 * 1000);
|
||||
|
||||
boost::thread::sleep(boost::get_system_time()
|
||||
+ boost::posix_time::milliseconds(sleep_time));
|
||||
sleep(sleep_time);
|
||||
}
|
||||
m_last_file_check = time_now_hires();
|
||||
#endif
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(p.is_complete());
|
||||
TORRENT_ASSERT((m & file::rw_mask) == file::read_only
|
||||
|| (m & file::rw_mask) == file::read_write);
|
||||
boost::mutex::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
file_set::iterator i = m_files.find(p.string());
|
||||
if (i != m_files.end())
|
||||
{
|
||||
|
@ -119,7 +119,7 @@ namespace libtorrent
|
|||
|
||||
void file_pool::release(fs::path const& p)
|
||||
{
|
||||
boost::mutex::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
|
||||
file_set::iterator i = m_files.find(p.string());
|
||||
if (i != m_files.end()) m_files.erase(i);
|
||||
|
@ -127,7 +127,7 @@ namespace libtorrent
|
|||
|
||||
void file_pool::release(void* st)
|
||||
{
|
||||
boost::mutex::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
TORRENT_ASSERT(st != 0);
|
||||
|
||||
for (file_set::iterator i = m_files.begin();
|
||||
|
@ -144,7 +144,7 @@ namespace libtorrent
|
|||
{
|
||||
TORRENT_ASSERT(size > 0);
|
||||
if (size == m_size) return;
|
||||
boost::mutex::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
m_size = size;
|
||||
if (int(m_files.size()) <= m_size) return;
|
||||
|
||||
|
|
|
@ -49,7 +49,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <boost/asio/ip/host_name.hpp>
|
||||
#include <boost/asio/ip/multicast.hpp>
|
||||
#endif
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <cstdlib>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ natpmp::natpmp(io_service& ios, address const& listen_interface
|
|||
|
||||
void natpmp::rebind(address const& listen_interface)
|
||||
{
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
|
||||
error_code ec;
|
||||
address gateway = get_default_gateway(m_socket.get_io_service(), ec);
|
||||
|
@ -121,7 +121,7 @@ void natpmp::rebind(address const& listen_interface)
|
|||
|
||||
bool natpmp::get_mapping(int index, int& local_port, int& external_port, int& protocol) const
|
||||
{
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
|
||||
TORRENT_ASSERT(index < int(m_mappings.size()) && index >= 0);
|
||||
if (index >= int(m_mappings.size()) || index < 0) return false;
|
||||
|
@ -133,14 +133,14 @@ bool natpmp::get_mapping(int index, int& local_port, int& external_port, int& pr
|
|||
return true;
|
||||
}
|
||||
|
||||
void natpmp::log(char const* msg, mutex_t::scoped_lock& l)
|
||||
void natpmp::log(char const* msg, mutex::scoped_lock& l)
|
||||
{
|
||||
l.unlock();
|
||||
m_log_callback(msg);
|
||||
l.lock();
|
||||
}
|
||||
|
||||
void natpmp::disable(error_code const& ec, mutex_t::scoped_lock& l)
|
||||
void natpmp::disable(error_code const& ec, mutex::scoped_lock& l)
|
||||
{
|
||||
m_disabled = true;
|
||||
|
||||
|
@ -159,7 +159,7 @@ void natpmp::disable(error_code const& ec, mutex_t::scoped_lock& l)
|
|||
|
||||
void natpmp::delete_mapping(int index)
|
||||
{
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
|
||||
TORRENT_ASSERT(index < int(m_mappings.size()) && index >= 0);
|
||||
if (index >= int(m_mappings.size()) || index < 0) return;
|
||||
|
@ -179,7 +179,7 @@ void natpmp::delete_mapping(int index)
|
|||
|
||||
int natpmp::add_mapping(protocol_type p, int external_port, int local_port)
|
||||
{
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
|
||||
if (m_disabled) return -1;
|
||||
|
||||
|
@ -201,7 +201,7 @@ int natpmp::add_mapping(protocol_type p, int external_port, int local_port)
|
|||
return mapping_index;
|
||||
}
|
||||
|
||||
void natpmp::try_next_mapping(int i, mutex_t::scoped_lock& l)
|
||||
void natpmp::try_next_mapping(int i, mutex::scoped_lock& l)
|
||||
{
|
||||
/*
|
||||
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
|
||||
|
@ -250,7 +250,7 @@ void natpmp::try_next_mapping(int i, mutex_t::scoped_lock& l)
|
|||
update_mapping(m - m_mappings.begin(), l);
|
||||
}
|
||||
|
||||
void natpmp::update_mapping(int i, mutex_t::scoped_lock& l)
|
||||
void natpmp::update_mapping(int i, mutex::scoped_lock& l)
|
||||
{
|
||||
if (i == m_mappings.size())
|
||||
{
|
||||
|
@ -283,7 +283,7 @@ void natpmp::update_mapping(int i, mutex_t::scoped_lock& l)
|
|||
}
|
||||
}
|
||||
|
||||
void natpmp::send_map_request(int i, mutex_t::scoped_lock& l)
|
||||
void natpmp::send_map_request(int i, mutex::scoped_lock& l)
|
||||
{
|
||||
using namespace libtorrent::detail;
|
||||
|
||||
|
@ -334,7 +334,7 @@ void natpmp::send_map_request(int i, mutex_t::scoped_lock& l)
|
|||
void natpmp::resend_request(int i, error_code const& e)
|
||||
{
|
||||
if (e) return;
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
if (m_currently_mapping != i) return;
|
||||
|
||||
// if we're shutting down, don't retry, just move on
|
||||
|
@ -354,7 +354,7 @@ void natpmp::resend_request(int i, error_code const& e)
|
|||
void natpmp::on_reply(error_code const& e
|
||||
, std::size_t bytes_transferred)
|
||||
{
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
|
||||
using namespace libtorrent::detail;
|
||||
if (e)
|
||||
|
@ -538,7 +538,7 @@ void natpmp::update_expiration_timer()
|
|||
void natpmp::mapping_expired(error_code const& e, int i)
|
||||
{
|
||||
if (e) return;
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
char msg[200];
|
||||
snprintf(msg, sizeof(msg), "mapping %u expired", i);
|
||||
log(msg, l);
|
||||
|
@ -549,11 +549,11 @@ void natpmp::mapping_expired(error_code const& e, int i)
|
|||
|
||||
void natpmp::close()
|
||||
{
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
close_impl(l);
|
||||
}
|
||||
|
||||
void natpmp::close_impl(mutex_t::scoped_lock& l)
|
||||
void natpmp::close_impl(mutex::scoped_lock& l)
|
||||
{
|
||||
m_abort = true;
|
||||
log("closing", l);
|
||||
|
|
|
@ -988,6 +988,7 @@ namespace libtorrent
|
|||
return;
|
||||
}
|
||||
|
||||
#if TORRENT_USE_I2P
|
||||
i2p_stream* i2ps = m_socket->get<i2p_stream>();
|
||||
if (!i2ps && t->torrent_file().is_i2p() && !m_ses.m_settings.allow_i2p_mixed)
|
||||
{
|
||||
|
@ -999,6 +1000,7 @@ namespace libtorrent
|
|||
disconnect(error_code(errors::peer_banned, libtorrent_category), 2);
|
||||
return;
|
||||
}
|
||||
#endif // TORRENT_USE_I2P
|
||||
|
||||
TORRENT_ASSERT(m_torrent.expired());
|
||||
// check to make sure we don't have another connection with the same
|
||||
|
@ -2261,7 +2263,7 @@ namespace libtorrent
|
|||
void peer_connection::on_disk_write_complete(int ret, disk_io_job const& j
|
||||
, peer_request p, boost::shared_ptr<torrent> t)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||
mutex::scoped_lock l(m_ses.m_mutex);
|
||||
|
||||
INVARIANT_CHECK;
|
||||
|
||||
|
@ -2976,7 +2978,7 @@ namespace libtorrent
|
|||
|
||||
void peer_connection::on_timeout()
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||
mutex::scoped_lock l(m_ses.m_mutex);
|
||||
|
||||
TORRENT_ASSERT(m_connecting);
|
||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
||||
|
@ -3811,7 +3813,7 @@ namespace libtorrent
|
|||
|
||||
void peer_connection::on_disk_read_complete(int ret, disk_io_job const& j, peer_request r)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||
mutex::scoped_lock l(m_ses.m_mutex);
|
||||
|
||||
m_reading_bytes -= r.length;
|
||||
|
||||
|
@ -4272,7 +4274,7 @@ namespace libtorrent
|
|||
void peer_connection::on_receive_data(const error_code& error
|
||||
, std::size_t bytes_transferred)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||
mutex::scoped_lock l(m_ses.m_mutex);
|
||||
|
||||
INVARIANT_CHECK;
|
||||
|
||||
|
@ -4443,7 +4445,7 @@ namespace libtorrent
|
|||
|
||||
void peer_connection::on_connect(int ticket)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||
mutex::scoped_lock l(m_ses.m_mutex);
|
||||
#ifdef TORRENT_DEBUG
|
||||
// in case we disconnect here, we need to
|
||||
// keep the connection alive until the
|
||||
|
@ -4533,7 +4535,7 @@ namespace libtorrent
|
|||
{
|
||||
ptime completed = time_now();
|
||||
|
||||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||
mutex::scoped_lock l(m_ses.m_mutex);
|
||||
|
||||
INVARIANT_CHECK;
|
||||
|
||||
|
@ -4596,7 +4598,7 @@ namespace libtorrent
|
|||
void peer_connection::on_send_data(error_code const& error
|
||||
, std::size_t bytes_transferred)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||
mutex::scoped_lock l(m_ses.m_mutex);
|
||||
|
||||
INVARIANT_CHECK;
|
||||
|
||||
|
|
|
@ -1611,20 +1611,19 @@ namespace libtorrent
|
|||
, piece_block(i->index, j));
|
||||
if (k != interesting_blocks.end()) continue;
|
||||
|
||||
std::cerr << "interesting blocks:" << std::endl;
|
||||
fprintf(stderr, "interesting blocks:\n");
|
||||
for (k = interesting_blocks.begin(); k != interesting_blocks.end(); ++k)
|
||||
std::cerr << "(" << k->piece_index << ", " << k->block_index << ") ";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "num_blocks: " << num_blocks << std::endl;
|
||||
fprintf(stderr, "(%d, %d)", k->piece_index, k->block_index);
|
||||
fprintf(stderr, "\nnum_blocks: %d\n", num_blocks);
|
||||
|
||||
for (std::vector<downloading_piece>::const_iterator l = m_downloads.begin()
|
||||
, end(m_downloads.end()); l != end; ++l)
|
||||
{
|
||||
std::cerr << l->index << " : ";
|
||||
fprintf(stderr, "%d : ", l->index);
|
||||
int num_blocks_in_piece = blocks_in_piece(l->index);
|
||||
for (int m = 0; m < num_blocks_in_piece; ++m)
|
||||
std::cerr << l->info[m].state;
|
||||
std::cerr << std::endl;
|
||||
fprintf(stderr, "%d", l->info[m].state);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
TORRENT_ASSERT(false);
|
||||
|
|
165
src/session.cpp
165
src/session.cpp
|
@ -253,13 +253,6 @@ namespace libtorrent
|
|||
// turn off the filename checking in boost.filesystem
|
||||
TORRENT_ASSERT(listen_port_range.first > 0);
|
||||
TORRENT_ASSERT(listen_port_range.first < listen_port_range.second);
|
||||
#ifdef TORRENT_DEBUG
|
||||
// this test was added after it came to my attention
|
||||
// that devstudios managed c++ failed to generate
|
||||
// correct code for boost.function
|
||||
boost::function0<void> test = boost::ref(*m_impl);
|
||||
TORRENT_ASSERT(!test.empty());
|
||||
#endif
|
||||
set_alert_mask(alert_mask);
|
||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||
if (flags & add_default_plugins)
|
||||
|
@ -296,10 +289,6 @@ namespace libtorrent
|
|||
{
|
||||
#ifdef TORRENT_MEMDEBUG
|
||||
start_malloc_debug();
|
||||
#endif
|
||||
#ifdef TORRENT_DEBUG
|
||||
boost::function0<void> test = boost::ref(*m_impl);
|
||||
TORRENT_ASSERT(!test.empty());
|
||||
#endif
|
||||
set_alert_mask(alert_mask);
|
||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||
|
@ -324,7 +313,7 @@ namespace libtorrent
|
|||
|
||||
session::~session()
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
#ifdef TORRENT_MEMDEBUG
|
||||
stop_malloc_debug();
|
||||
#endif
|
||||
|
@ -339,7 +328,7 @@ namespace libtorrent
|
|||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||
void session::add_extension(boost::function<boost::shared_ptr<torrent_plugin>(torrent*, void*)> ext)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
m_impl->add_extension(ext);
|
||||
}
|
||||
#endif
|
||||
|
@ -347,32 +336,32 @@ namespace libtorrent
|
|||
#ifndef TORRENT_DISABLE_GEO_IP
|
||||
bool session::load_asnum_db(char const* file)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
return m_impl->load_asnum_db(file);
|
||||
}
|
||||
|
||||
bool session::load_country_db(char const* file)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
return m_impl->load_country_db(file);
|
||||
}
|
||||
|
||||
int session::as_for_ip(address const& addr)
|
||||
{
|
||||
aux::session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
aux::mutex::scoped_lock l(m_impl->m_mutex);
|
||||
return m_impl->as_for_ip(addr);
|
||||
}
|
||||
|
||||
#ifndef BOOST_FILESYSTEM_NARROW_ONLY
|
||||
bool session::load_asnum_db(wchar_t const* file)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
return m_impl->load_asnum_db(file);
|
||||
}
|
||||
|
||||
bool session::load_country_db(wchar_t const* file)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
return m_impl->load_country_db(file);
|
||||
}
|
||||
#endif
|
||||
|
@ -380,74 +369,74 @@ namespace libtorrent
|
|||
|
||||
void session::load_state(entry const& ses_state)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
m_impl->load_state(ses_state);
|
||||
}
|
||||
|
||||
entry session::state() const
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
return m_impl->state();
|
||||
}
|
||||
|
||||
void session::set_ip_filter(ip_filter const& f)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
m_impl->set_ip_filter(f);
|
||||
}
|
||||
|
||||
ip_filter const& session::get_ip_filter() const
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
return m_impl->get_ip_filter();
|
||||
}
|
||||
|
||||
void session::set_port_filter(port_filter const& f)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
m_impl->set_port_filter(f);
|
||||
}
|
||||
|
||||
void session::set_peer_id(peer_id const& id)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
m_impl->set_peer_id(id);
|
||||
}
|
||||
|
||||
peer_id session::id() const
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
return m_impl->get_peer_id();
|
||||
}
|
||||
|
||||
io_service& session::get_io_service()
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
return m_impl->m_io_service;
|
||||
}
|
||||
|
||||
void session::set_key(int key)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
m_impl->set_key(key);
|
||||
}
|
||||
|
||||
std::vector<torrent_handle> session::get_torrents() const
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
return m_impl->get_torrents();
|
||||
}
|
||||
|
||||
torrent_handle session::find_torrent(sha1_hash const& info_hash) const
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
return m_impl->find_torrent_handle(info_hash);
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
torrent_handle session::add_torrent(add_torrent_params const& params)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
|
||||
error_code ec;
|
||||
torrent_handle ret = m_impl->add_torrent(params, ec);
|
||||
|
@ -458,7 +447,7 @@ namespace libtorrent
|
|||
|
||||
torrent_handle session::add_torrent(add_torrent_params const& params, error_code& ec)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
return m_impl->add_torrent(params, ec);
|
||||
}
|
||||
|
||||
|
@ -536,7 +525,7 @@ namespace libtorrent
|
|||
|
||||
void session::remove_torrent(const torrent_handle& h, int options)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
m_impl->remove_torrent(h, options);
|
||||
}
|
||||
|
||||
|
@ -544,50 +533,50 @@ namespace libtorrent
|
|||
std::pair<int, int> const& port_range
|
||||
, const char* net_interface)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
return m_impl->listen_on(port_range, net_interface);
|
||||
}
|
||||
|
||||
unsigned short session::listen_port() const
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
return m_impl->listen_port();
|
||||
}
|
||||
|
||||
session_status session::status() const
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
return m_impl->status();
|
||||
}
|
||||
|
||||
void session::pause()
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
m_impl->pause();
|
||||
}
|
||||
|
||||
void session::resume()
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
m_impl->resume();
|
||||
}
|
||||
|
||||
bool session::is_paused() const
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
return m_impl->is_paused();
|
||||
}
|
||||
|
||||
void session::get_cache_info(sha1_hash const& ih
|
||||
, std::vector<cached_piece_info>& ret) const
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
m_impl->m_disk_thread.get_cache_info(ih, ret);
|
||||
}
|
||||
|
||||
cache_status session::get_cache_status() const
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
return m_impl->m_disk_thread.status();
|
||||
}
|
||||
|
||||
|
@ -595,37 +584,37 @@ namespace libtorrent
|
|||
|
||||
void session::start_dht(entry const& startup_state)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
m_impl->start_dht(startup_state);
|
||||
}
|
||||
|
||||
void session::stop_dht()
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
m_impl->stop_dht();
|
||||
}
|
||||
|
||||
void session::set_dht_settings(dht_settings const& settings)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
m_impl->set_dht_settings(settings);
|
||||
}
|
||||
|
||||
entry session::dht_state() const
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
return m_impl->dht_state(l);
|
||||
}
|
||||
|
||||
void session::add_dht_node(std::pair<std::string, int> const& node)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
m_impl->add_dht_node(node);
|
||||
}
|
||||
|
||||
void session::add_dht_router(std::pair<std::string, int> const& node)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
m_impl->add_dht_router(node);
|
||||
}
|
||||
|
||||
|
@ -634,68 +623,68 @@ namespace libtorrent
|
|||
#ifndef TORRENT_DISABLE_ENCRYPTION
|
||||
void session::set_pe_settings(pe_settings const& settings)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
m_impl->set_pe_settings(settings);
|
||||
}
|
||||
|
||||
pe_settings const& session::get_pe_settings() const
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
return m_impl->get_pe_settings();
|
||||
}
|
||||
#endif
|
||||
|
||||
bool session::is_listening() const
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
return m_impl->is_listening();
|
||||
}
|
||||
|
||||
void session::set_settings(session_settings const& s)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
m_impl->set_settings(s);
|
||||
}
|
||||
|
||||
session_settings const& session::settings()
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
return m_impl->settings();
|
||||
}
|
||||
|
||||
void session::set_peer_proxy(proxy_settings const& s)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
m_impl->set_peer_proxy(s);
|
||||
}
|
||||
|
||||
void session::set_web_seed_proxy(proxy_settings const& s)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
m_impl->set_web_seed_proxy(s);
|
||||
}
|
||||
|
||||
void session::set_tracker_proxy(proxy_settings const& s)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
m_impl->set_tracker_proxy(s);
|
||||
}
|
||||
|
||||
proxy_settings const& session::peer_proxy() const
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
return m_impl->peer_proxy();
|
||||
}
|
||||
|
||||
proxy_settings const& session::web_seed_proxy() const
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
return m_impl->web_seed_proxy();
|
||||
}
|
||||
|
||||
proxy_settings const& session::tracker_proxy() const
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
return m_impl->tracker_proxy();
|
||||
}
|
||||
|
||||
|
@ -703,13 +692,13 @@ namespace libtorrent
|
|||
#ifndef TORRENT_DISABLE_DHT
|
||||
void session::set_dht_proxy(proxy_settings const& s)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
m_impl->set_dht_proxy(s);
|
||||
}
|
||||
|
||||
proxy_settings const& session::dht_proxy() const
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
return m_impl->dht_proxy();
|
||||
}
|
||||
#endif
|
||||
|
@ -717,116 +706,116 @@ namespace libtorrent
|
|||
#if TORRENT_USE_I2P
|
||||
void session::set_i2p_proxy(proxy_settings const& s)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
m_impl->set_i2p_proxy(s);
|
||||
}
|
||||
|
||||
proxy_settings const& session::i2p_proxy() const
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
return m_impl->i2p_proxy();
|
||||
}
|
||||
#endif
|
||||
|
||||
int session::max_uploads() const
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
return m_impl->max_uploads();
|
||||
}
|
||||
|
||||
void session::set_max_uploads(int limit)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
m_impl->set_max_uploads(limit);
|
||||
}
|
||||
|
||||
int session::max_connections() const
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
return m_impl->max_connections();
|
||||
}
|
||||
|
||||
void session::set_max_connections(int limit)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
m_impl->set_max_connections(limit);
|
||||
}
|
||||
|
||||
int session::max_half_open_connections() const
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
return m_impl->max_half_open_connections();
|
||||
}
|
||||
|
||||
void session::set_max_half_open_connections(int limit)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
m_impl->set_max_half_open_connections(limit);
|
||||
}
|
||||
|
||||
int session::local_upload_rate_limit() const
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
return m_impl->local_upload_rate_limit();
|
||||
}
|
||||
|
||||
int session::local_download_rate_limit() const
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
return m_impl->local_download_rate_limit();
|
||||
}
|
||||
|
||||
int session::upload_rate_limit() const
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
return m_impl->upload_rate_limit();
|
||||
}
|
||||
|
||||
int session::download_rate_limit() const
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
return m_impl->download_rate_limit();
|
||||
}
|
||||
|
||||
void session::set_local_upload_rate_limit(int bytes_per_second)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
m_impl->set_local_upload_rate_limit(bytes_per_second);
|
||||
}
|
||||
|
||||
void session::set_local_download_rate_limit(int bytes_per_second)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
m_impl->set_local_download_rate_limit(bytes_per_second);
|
||||
}
|
||||
|
||||
void session::set_upload_rate_limit(int bytes_per_second)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
m_impl->set_upload_rate_limit(bytes_per_second);
|
||||
}
|
||||
|
||||
void session::set_download_rate_limit(int bytes_per_second)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
m_impl->set_download_rate_limit(bytes_per_second);
|
||||
}
|
||||
|
||||
int session::num_uploads() const
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
return m_impl->num_uploads();
|
||||
}
|
||||
|
||||
int session::num_connections() const
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
return m_impl->num_connections();
|
||||
}
|
||||
|
||||
std::auto_ptr<alert> session::pop_alert()
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
return m_impl->pop_alert();
|
||||
}
|
||||
|
||||
|
@ -844,20 +833,20 @@ namespace libtorrent
|
|||
|
||||
void session::set_alert_mask(int m)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
m_impl->set_alert_mask(m);
|
||||
}
|
||||
|
||||
size_t session::set_alert_queue_size_limit(size_t queue_size_limit_)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
return m_impl->set_alert_queue_size_limit(queue_size_limit_);
|
||||
}
|
||||
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
void session::set_severity_level(alert::severity_t s)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
int m = 0;
|
||||
switch (s)
|
||||
{
|
||||
|
@ -878,13 +867,13 @@ namespace libtorrent
|
|||
|
||||
void session::start_lsd()
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
m_impl->start_lsd();
|
||||
}
|
||||
|
||||
natpmp* session::start_natpmp()
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
if (m_impl->m_natpmp) return m_impl->m_natpmp.get();
|
||||
|
||||
// the natpmp constructor may fail and call the callbacks
|
||||
|
@ -906,7 +895,7 @@ namespace libtorrent
|
|||
|
||||
upnp* session::start_upnp()
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
|
||||
if (m_impl->m_upnp) return m_impl->m_upnp.get();
|
||||
|
||||
|
@ -932,25 +921,25 @@ namespace libtorrent
|
|||
|
||||
void session::stop_lsd()
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
m_impl->stop_lsd();
|
||||
}
|
||||
|
||||
void session::stop_natpmp()
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
m_impl->stop_natpmp();
|
||||
}
|
||||
|
||||
void session::stop_upnp()
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
m_impl->stop_upnp();
|
||||
}
|
||||
|
||||
connection_queue& session::get_connection_queue()
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
mutex::scoped_lock l(m_impl->m_mutex);
|
||||
return m_impl->m_half_open;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -361,7 +361,7 @@ namespace aux {
|
|||
m_timer.expires_from_now(milliseconds(100), ec);
|
||||
m_timer.async_wait(bind(&session_impl::on_tick, this, _1));
|
||||
|
||||
m_thread.reset(new boost::thread(boost::ref(*this)));
|
||||
m_thread.reset(new thread(boost::bind(&session_impl::main_thread, this)));
|
||||
}
|
||||
|
||||
#ifndef TORRENT_DISABLE_GEO_IP
|
||||
|
@ -1240,7 +1240,7 @@ namespace aux {
|
|||
// wake them up
|
||||
void session_impl::on_disk_queue()
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
|
||||
for (connection_map::iterator i = m_connections.begin()
|
||||
, end(m_connections.end()); i != end; ++i)
|
||||
|
@ -1254,7 +1254,7 @@ namespace aux {
|
|||
|
||||
void session_impl::on_tick(error_code const& e)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
|
||||
ptime now = time_now_hires();
|
||||
aux::g_current_time = now;
|
||||
|
@ -1503,8 +1503,8 @@ namespace aux {
|
|||
m_stat.second_tick(tick_interval_ms);
|
||||
|
||||
TORRENT_ASSERT(least_recently_scraped == m_torrents.end()
|
||||
|| least_recently_scraped->second->is_paused()
|
||||
&& least_recently_scraped->second->is_auto_managed());
|
||||
|| (least_recently_scraped->second->is_paused()
|
||||
&& least_recently_scraped->second->is_auto_managed()));
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// scrape paused torrents that are auto managed
|
||||
|
@ -2073,13 +2073,13 @@ namespace aux {
|
|||
}
|
||||
}
|
||||
|
||||
void session_impl::operator()()
|
||||
void session_impl::main_thread()
|
||||
{
|
||||
eh_initializer();
|
||||
|
||||
if (m_listen_interface.port() != 0)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
open_listen_port();
|
||||
}
|
||||
|
||||
|
@ -2091,7 +2091,7 @@ namespace aux {
|
|||
if (ec)
|
||||
{
|
||||
#ifdef TORRENT_DEBUG
|
||||
std::cerr << ec.message() << "\n";
|
||||
fprintf(stderr, "%s\n", ec.message().c_str());
|
||||
std::string err = ec.message();
|
||||
#endif
|
||||
TORRENT_ASSERT(false);
|
||||
|
@ -2104,7 +2104,7 @@ namespace aux {
|
|||
(*m_logger) << time_now_string() << " locking mutex\n";
|
||||
#endif
|
||||
|
||||
session_impl::mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
/*
|
||||
#ifdef TORRENT_DEBUG
|
||||
for (torrent_map::iterator i = m_torrents.begin();
|
||||
|
@ -2389,7 +2389,7 @@ namespace aux {
|
|||
|
||||
void session_impl::on_lsd_peer(tcp::endpoint peer, sha1_hash const& ih)
|
||||
{
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
|
||||
INVARIANT_CHECK;
|
||||
|
||||
|
@ -2423,7 +2423,7 @@ namespace aux {
|
|||
void session_impl::on_port_mapping(int mapping, int port
|
||||
, error_code const& ec, int map_transport)
|
||||
{
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
TORRENT_ASSERT(map_transport >= 0 && map_transport <= 1);
|
||||
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
|
@ -2642,18 +2642,18 @@ namespace aux {
|
|||
m_dht_settings.service_port = m_listen_interface.port();
|
||||
}
|
||||
|
||||
void session_impl::on_dht_state_callback(boost::condition& c
|
||||
void session_impl::on_dht_state_callback(condition& c
|
||||
, entry& e, bool& done) const
|
||||
{
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
if (m_dht) e = m_dht->state();
|
||||
done = true;
|
||||
c.notify_all();
|
||||
c.signal(l);
|
||||
}
|
||||
|
||||
entry session_impl::dht_state(session_impl::mutex_t::scoped_lock& l) const
|
||||
entry session_impl::dht_state(mutex::scoped_lock& l) const
|
||||
{
|
||||
boost::condition cond;
|
||||
condition cond;
|
||||
if (!m_dht) return entry();
|
||||
entry e;
|
||||
bool done = false;
|
||||
|
@ -2692,7 +2692,7 @@ namespace aux {
|
|||
|
||||
session_impl::~session_impl()
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
|
||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
||||
(*m_logger) << time_now_string() << "\n\n *** shutting down session *** \n\n";
|
||||
|
@ -2955,7 +2955,7 @@ namespace aux {
|
|||
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);
|
||||
mutex::scoped_lock l(m_send_buffer_mutex);
|
||||
#ifdef TORRENT_STATS
|
||||
TORRENT_ASSERT(m_buffer_allocations >= 0);
|
||||
m_buffer_allocations += num_buffers;
|
||||
|
@ -2997,7 +2997,7 @@ namespace aux {
|
|||
int num_buffers = size / send_buffer_size;
|
||||
TORRENT_ASSERT(num_buffers > 0);
|
||||
|
||||
boost::mutex::scoped_lock l(m_send_buffer_mutex);
|
||||
mutex::scoped_lock l(m_send_buffer_mutex);
|
||||
#ifdef TORRENT_STATS
|
||||
m_buffer_allocations -= num_buffers;
|
||||
TORRENT_ASSERT(m_buffer_allocations >= 0);
|
||||
|
|
|
@ -165,7 +165,7 @@ namespace libtorrent { namespace
|
|||
|
||||
void on_read_failed_block(piece_block b, address a, int ret, disk_io_job const& j)
|
||||
{
|
||||
aux::session_impl::mutex_t::scoped_lock l(m_torrent.session().m_mutex);
|
||||
mutex::scoped_lock l(m_torrent.session().m_mutex);
|
||||
|
||||
disk_buffer_holder buffer(m_torrent.session(), j.buffer);
|
||||
|
||||
|
@ -246,7 +246,7 @@ namespace libtorrent { namespace
|
|||
|
||||
void on_read_ok_block(std::pair<piece_block, block_entry> b, int ret, disk_io_job const& j)
|
||||
{
|
||||
aux::session_impl::mutex_t::scoped_lock l(m_torrent.session().m_mutex);
|
||||
mutex::scoped_lock l(m_torrent.session().m_mutex);
|
||||
|
||||
disk_buffer_holder buffer(m_torrent.session(), j.buffer);
|
||||
|
||||
|
|
|
@ -1703,7 +1703,7 @@ ret:
|
|||
TORRENT_ASSERT(r.length <= 16 * 1024);
|
||||
m_io_thread.add_job(j, handler);
|
||||
#ifdef TORRENT_DEBUG
|
||||
boost::recursive_mutex::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
// if this assert is hit, it suggests
|
||||
// that check_files was not successful
|
||||
TORRENT_ASSERT(slot_for(r.piece) >= 0);
|
||||
|
@ -1728,7 +1728,7 @@ ret:
|
|||
TORRENT_ASSERT(r.length <= 16 * 1024);
|
||||
m_io_thread.add_job(j, handler);
|
||||
#ifdef TORRENT_DEBUG
|
||||
boost::recursive_mutex::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
// if this assert is hit, it suggests
|
||||
// that check_files was not successful
|
||||
TORRENT_ASSERT(slot_for(r.piece) >= 0);
|
||||
|
@ -1773,7 +1773,7 @@ ret:
|
|||
|
||||
fs::path piece_manager::save_path() const
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
return m_save_path;
|
||||
}
|
||||
|
||||
|
@ -1807,7 +1807,7 @@ ret:
|
|||
|
||||
void piece_manager::write_resume_data(entry& rd) const
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock lock(m_mutex);
|
||||
mutex::scoped_lock lock(m_mutex);
|
||||
|
||||
INVARIANT_CHECK;
|
||||
|
||||
|
@ -1838,6 +1838,8 @@ ret:
|
|||
|
||||
void piece_manager::mark_failed(int piece_index)
|
||||
{
|
||||
mutex::scoped_lock lock(m_mutex);
|
||||
|
||||
INVARIANT_CHECK;
|
||||
|
||||
if (m_storage_mode != storage_mode_compact) return;
|
||||
|
@ -2156,7 +2158,7 @@ ret:
|
|||
int piece_manager::check_fastresume(
|
||||
lazy_entry const& rd, error_code& error)
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock lock(m_mutex);
|
||||
mutex::scoped_lock lock(m_mutex);
|
||||
|
||||
INVARIANT_CHECK;
|
||||
|
||||
|
@ -2867,7 +2869,7 @@ ret:
|
|||
|
||||
int piece_manager::allocate_slot_for_piece(int piece_index)
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock lock(m_mutex);
|
||||
mutex::scoped_lock lock(m_mutex);
|
||||
|
||||
if (m_storage_mode != storage_mode_compact) return piece_index;
|
||||
|
||||
|
@ -2982,7 +2984,7 @@ ret:
|
|||
|
||||
bool piece_manager::allocate_slots(int num_slots, bool abort_on_disk)
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock lock(m_mutex);
|
||||
mutex::scoped_lock lock(m_mutex);
|
||||
TORRENT_ASSERT(num_slots > 0);
|
||||
|
||||
INVARIANT_CHECK;
|
||||
|
@ -3039,8 +3041,6 @@ ret:
|
|||
#ifdef TORRENT_DEBUG
|
||||
void piece_manager::check_invariant() const
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock lock(m_mutex);
|
||||
|
||||
TORRENT_ASSERT(m_current_slot <= m_files.num_pieces());
|
||||
|
||||
if (m_unallocated_slots.empty()
|
||||
|
|
|
@ -49,7 +49,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include <boost/filesystem/convenience.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/thread/mutex.hpp>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
|
@ -504,7 +503,7 @@ namespace libtorrent
|
|||
|
||||
void torrent::on_disk_read_complete(int ret, disk_io_job const& j, peer_request r, read_piece_struct* rp)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||
mutex::scoped_lock l(m_ses.m_mutex);
|
||||
|
||||
disk_buffer_holder buffer(m_ses, j.buffer);
|
||||
|
||||
|
@ -575,7 +574,7 @@ namespace libtorrent
|
|||
void torrent::on_disk_write_complete(int ret, disk_io_job const& j
|
||||
, peer_request p)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||
mutex::scoped_lock l(m_ses.m_mutex);
|
||||
|
||||
INVARIANT_CHECK;
|
||||
|
||||
|
@ -776,7 +775,7 @@ namespace libtorrent
|
|||
|
||||
void torrent::on_resume_data_checked(int ret, disk_io_job const& j)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||
mutex::scoped_lock l(m_ses.m_mutex);
|
||||
|
||||
if (ret == piece_manager::fatal_disk_error)
|
||||
{
|
||||
|
@ -1024,7 +1023,7 @@ namespace libtorrent
|
|||
|
||||
void torrent::on_force_recheck(int ret, disk_io_job const& j)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||
mutex::scoped_lock l(m_ses.m_mutex);
|
||||
|
||||
if (ret == piece_manager::fatal_disk_error)
|
||||
{
|
||||
|
@ -1056,7 +1055,7 @@ namespace libtorrent
|
|||
|
||||
void torrent::on_piece_checked(int ret, disk_io_job const& j)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||
mutex::scoped_lock l(m_ses.m_mutex);
|
||||
INVARIANT_CHECK;
|
||||
|
||||
if (ret == piece_manager::disk_check_aborted)
|
||||
|
@ -1118,7 +1117,7 @@ namespace libtorrent
|
|||
|
||||
void torrent::on_tracker_announce()
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||
mutex::scoped_lock l(m_ses.m_mutex);
|
||||
m_waiting_tracker = false;
|
||||
if (m_abort) return;
|
||||
announce_with_tracker();
|
||||
|
@ -1135,7 +1134,7 @@ namespace libtorrent
|
|||
|
||||
void torrent::on_lsd_announce()
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||
mutex::scoped_lock l(m_ses.m_mutex);
|
||||
|
||||
if (m_abort) return;
|
||||
|
||||
|
@ -1332,7 +1331,7 @@ namespace libtorrent
|
|||
|
||||
void torrent::tracker_warning(tracker_request const& req, std::string const& msg)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||
mutex::scoped_lock l(m_ses.m_mutex);
|
||||
|
||||
INVARIANT_CHECK;
|
||||
|
||||
|
@ -1343,7 +1342,7 @@ namespace libtorrent
|
|||
void torrent::tracker_scrape_response(tracker_request const& req
|
||||
, int complete, int incomplete, int downloaded)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||
mutex::scoped_lock l(m_ses.m_mutex);
|
||||
|
||||
INVARIANT_CHECK;
|
||||
TORRENT_ASSERT(req.kind == tracker_request::scrape_request);
|
||||
|
@ -1368,7 +1367,7 @@ namespace libtorrent
|
|||
, int incomplete
|
||||
, address const& external_ip)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||
mutex::scoped_lock l(m_ses.m_mutex);
|
||||
|
||||
INVARIANT_CHECK;
|
||||
TORRENT_ASSERT(r.kind == tracker_request::announce_request);
|
||||
|
@ -1517,7 +1516,7 @@ namespace libtorrent
|
|||
#if TORRENT_USE_I2P
|
||||
void torrent::on_i2p_resolve(error_code const& ec, char const* dest)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||
mutex::scoped_lock l(m_ses.m_mutex);
|
||||
|
||||
INVARIANT_CHECK;
|
||||
|
||||
|
@ -1530,7 +1529,7 @@ namespace libtorrent
|
|||
void torrent::on_peer_name_lookup(error_code const& e, tcp::resolver::iterator host
|
||||
, peer_id pid)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||
mutex::scoped_lock l(m_ses.m_mutex);
|
||||
|
||||
INVARIANT_CHECK;
|
||||
|
||||
|
@ -2302,7 +2301,7 @@ namespace libtorrent
|
|||
|
||||
void torrent::on_files_deleted(int ret, disk_io_job const& j)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||
mutex::scoped_lock l(m_ses.m_mutex);
|
||||
|
||||
if (ret != 0)
|
||||
{
|
||||
|
@ -2319,7 +2318,7 @@ namespace libtorrent
|
|||
void torrent::on_files_released(int ret, disk_io_job const& j)
|
||||
{
|
||||
/*
|
||||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||
mutex::scoped_lock l(m_ses.m_mutex);
|
||||
|
||||
if (alerts().should_post<torrent_paused_alert>())
|
||||
{
|
||||
|
@ -2330,7 +2329,7 @@ namespace libtorrent
|
|||
|
||||
void torrent::on_save_resume_data(int ret, disk_io_job const& j)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||
mutex::scoped_lock l(m_ses.m_mutex);
|
||||
|
||||
if (!j.resume_data)
|
||||
{
|
||||
|
@ -2346,7 +2345,7 @@ namespace libtorrent
|
|||
|
||||
void torrent::on_file_renamed(int ret, disk_io_job const& j)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||
mutex::scoped_lock l(m_ses.m_mutex);
|
||||
|
||||
if (ret == 0)
|
||||
{
|
||||
|
@ -2364,7 +2363,7 @@ namespace libtorrent
|
|||
|
||||
void torrent::on_torrent_paused(int ret, disk_io_job const& j)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||
mutex::scoped_lock l(m_ses.m_mutex);
|
||||
|
||||
if (alerts().should_post<torrent_paused_alert>())
|
||||
alerts().post_alert(torrent_paused_alert(get_handle()));
|
||||
|
@ -3063,7 +3062,7 @@ namespace libtorrent
|
|||
void torrent::on_proxy_name_lookup(error_code const& e, tcp::resolver::iterator host
|
||||
, web_seed_entry web)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||
mutex::scoped_lock l(m_ses.m_mutex);
|
||||
|
||||
INVARIANT_CHECK;
|
||||
|
||||
|
@ -3124,7 +3123,7 @@ namespace libtorrent
|
|||
void torrent::on_name_lookup(error_code const& e, tcp::resolver::iterator host
|
||||
, web_seed_entry web, tcp::endpoint proxy)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||
mutex::scoped_lock l(m_ses.m_mutex);
|
||||
|
||||
INVARIANT_CHECK;
|
||||
|
||||
|
@ -3280,7 +3279,7 @@ namespace libtorrent
|
|||
void torrent::on_country_lookup(error_code const& error, tcp::resolver::iterator i
|
||||
, intrusive_ptr<peer_connection> p) const
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||
mutex::scoped_lock l(m_ses.m_mutex);
|
||||
|
||||
INVARIANT_CHECK;
|
||||
|
||||
|
@ -4348,11 +4347,11 @@ namespace libtorrent
|
|||
|
||||
void torrent::files_checked_lock()
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||
mutex::scoped_lock l(m_ses.m_mutex);
|
||||
files_checked(l);
|
||||
}
|
||||
|
||||
void torrent::files_checked(session_impl::mutex_t::scoped_lock const& l)
|
||||
void torrent::files_checked(mutex::scoped_lock const& l)
|
||||
{
|
||||
TORRENT_ASSERT(m_torrent_file->is_valid());
|
||||
|
||||
|
@ -4476,7 +4475,7 @@ namespace libtorrent
|
|||
|
||||
void torrent::on_storage_moved(int ret, disk_io_job const& j)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||
mutex::scoped_lock l(m_ses.m_mutex);
|
||||
|
||||
if (ret == 0)
|
||||
{
|
||||
|
@ -5523,7 +5522,7 @@ namespace libtorrent
|
|||
void torrent::on_piece_verified(int ret, disk_io_job const& j
|
||||
, boost::function<void(int)> f)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||
mutex::scoped_lock l(m_ses.m_mutex);
|
||||
|
||||
// return value:
|
||||
// 0: success, piece passed hash check
|
||||
|
@ -5929,7 +5928,7 @@ namespace libtorrent
|
|||
void torrent::tracker_request_timed_out(
|
||||
tracker_request const& r)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||
mutex::scoped_lock l(m_ses.m_mutex);
|
||||
|
||||
INVARIANT_CHECK;
|
||||
|
||||
|
@ -5970,7 +5969,7 @@ namespace libtorrent
|
|||
void torrent::tracker_request_error(tracker_request const& r
|
||||
, int response_code, const std::string& str)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||
mutex::scoped_lock l(m_ses.m_mutex);
|
||||
|
||||
INVARIANT_CHECK;
|
||||
|
||||
|
|
|
@ -79,19 +79,19 @@ using libtorrent::aux::session_impl;
|
|||
#define TORRENT_FORWARD(call) \
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock(); \
|
||||
if (!t) return; \
|
||||
session_impl::mutex_t::scoped_lock l(t->session().m_mutex); \
|
||||
mutex::scoped_lock l(t->session().m_mutex); \
|
||||
t->call
|
||||
|
||||
#define TORRENT_FORWARD_RETURN(call, def) \
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock(); \
|
||||
if (!t) return def; \
|
||||
session_impl::mutex_t::scoped_lock l(t->session().m_mutex); \
|
||||
mutex::scoped_lock l(t->session().m_mutex); \
|
||||
return t->call
|
||||
|
||||
#define TORRENT_FORWARD_RETURN2(call, def) \
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock(); \
|
||||
if (!t) return def; \
|
||||
session_impl::mutex_t::scoped_lock l(t->session().m_mutex); \
|
||||
mutex::scoped_lock l(t->session().m_mutex); \
|
||||
t->call
|
||||
|
||||
#else
|
||||
|
@ -99,19 +99,19 @@ using libtorrent::aux::session_impl;
|
|||
#define TORRENT_FORWARD(call) \
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock(); \
|
||||
if (!t) throw_invalid_handle(); \
|
||||
session_impl::mutex_t::scoped_lock l(t->session().m_mutex); \
|
||||
mutex::scoped_lock l(t->session().m_mutex); \
|
||||
t->call
|
||||
|
||||
#define TORRENT_FORWARD_RETURN(call, def) \
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock(); \
|
||||
if (!t) throw_invalid_handle(); \
|
||||
session_impl::mutex_t::scoped_lock l(t->session().m_mutex); \
|
||||
mutex::scoped_lock l(t->session().m_mutex); \
|
||||
return t->call
|
||||
|
||||
#define TORRENT_FORWARD_RETURN2(call, def) \
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock(); \
|
||||
if (!t) throw_invalid_handle(); \
|
||||
session_impl::mutex_t::scoped_lock l(t->session().m_mutex); \
|
||||
mutex::scoped_lock l(t->session().m_mutex); \
|
||||
t->call
|
||||
|
||||
#endif
|
||||
|
@ -601,7 +601,7 @@ namespace libtorrent
|
|||
#else
|
||||
throw_invalid_handle();
|
||||
#endif
|
||||
session_impl::mutex_t::scoped_lock l(t->session().m_mutex);
|
||||
mutex::scoped_lock l(t->session().m_mutex);
|
||||
if (!t->valid_metadata())
|
||||
#ifdef BOOST_NO_EXCEPTIONS
|
||||
return empty;
|
||||
|
@ -647,7 +647,7 @@ namespace libtorrent
|
|||
#else
|
||||
throw_invalid_handle();
|
||||
#endif
|
||||
session_impl::mutex_t::scoped_lock l(t->session().m_mutex);
|
||||
mutex::scoped_lock l(t->session().m_mutex);
|
||||
|
||||
peer_id id;
|
||||
std::fill(id.begin(), id.end(), 0);
|
||||
|
|
|
@ -183,13 +183,13 @@ namespace libtorrent
|
|||
|
||||
void tracker_manager::sent_bytes(int bytes)
|
||||
{
|
||||
// aux::session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||
// mutex::scoped_lock l(m_ses.m_mutex);
|
||||
m_ses.m_stat.sent_tracker_bytes(bytes);
|
||||
}
|
||||
|
||||
void tracker_manager::received_bytes(int bytes)
|
||||
{
|
||||
aux::session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||
mutex::scoped_lock l(m_ses.m_mutex);
|
||||
m_ses.m_stat.received_tracker_bytes(bytes);
|
||||
}
|
||||
|
||||
|
@ -269,34 +269,30 @@ namespace libtorrent
|
|||
mutex_t::scoped_lock l(m_mutex);
|
||||
|
||||
m_abort = true;
|
||||
tracker_connections_t keep_connections;
|
||||
tracker_connections_t close_connections;
|
||||
|
||||
while (!m_connections.empty())
|
||||
for (tracker_connections_t::iterator i = m_connections.begin()
|
||||
, end(m_connections.end()); i != end; ++i)
|
||||
{
|
||||
boost::intrusive_ptr<tracker_connection>& c = m_connections.back();
|
||||
if (!c)
|
||||
{
|
||||
m_connections.pop_back();
|
||||
continue;
|
||||
}
|
||||
intrusive_ptr<tracker_connection> c = *i;
|
||||
tracker_request const& req = c->tracker_req();
|
||||
if (req.event == tracker_request::stopped && !all)
|
||||
{
|
||||
keep_connections.push_back(c);
|
||||
m_connections.pop_back();
|
||||
continue;
|
||||
}
|
||||
// close will remove the entry from m_connections
|
||||
// so no need to pop
|
||||
|
||||
close_connections.push_back(c);
|
||||
|
||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
||||
boost::shared_ptr<request_callback> rc = c->requester();
|
||||
if (rc) rc->debug_log("aborting: " + req.url);
|
||||
#endif
|
||||
c->close();
|
||||
}
|
||||
l.unlock();
|
||||
|
||||
std::swap(m_connections, keep_connections);
|
||||
for (tracker_connections_t::iterator i = close_connections.begin()
|
||||
, end(close_connections.end()); i != end; ++i)
|
||||
{
|
||||
(*i)->close();
|
||||
}
|
||||
}
|
||||
|
||||
bool tracker_manager::empty() const
|
||||
|
|
|
@ -117,7 +117,7 @@ void udp_socket::send(udp::endpoint const& ep, char const* p, int len, error_cod
|
|||
void udp_socket::on_read(udp::socket* s, error_code const& e, std::size_t bytes_transferred)
|
||||
{
|
||||
TORRENT_ASSERT(m_magic == 0x1337);
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
|
||||
TORRENT_ASSERT(m_outstanding > 0);
|
||||
--m_outstanding;
|
||||
|
@ -332,7 +332,7 @@ void udp_socket::unwrap(error_code const& e, char const* buf, int size)
|
|||
|
||||
void udp_socket::close()
|
||||
{
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
TORRENT_ASSERT(m_magic == 0x1337);
|
||||
|
||||
error_code ec;
|
||||
|
@ -361,7 +361,7 @@ void udp_socket::close()
|
|||
void udp_socket::bind(udp::endpoint const& ep, error_code& ec)
|
||||
{
|
||||
CHECK_MAGIC;
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
|
||||
if (m_ipv4_sock.is_open()) m_ipv4_sock.close(ec);
|
||||
#if TORRENT_USE_IPV6
|
||||
|
@ -398,7 +398,7 @@ void udp_socket::bind(udp::endpoint const& ep, error_code& ec)
|
|||
void udp_socket::bind(int port)
|
||||
{
|
||||
CHECK_MAGIC;
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
|
||||
error_code ec;
|
||||
|
||||
|
@ -438,7 +438,7 @@ void udp_socket::bind(int port)
|
|||
void udp_socket::set_proxy_settings(proxy_settings const& ps)
|
||||
{
|
||||
CHECK_MAGIC;
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
|
||||
error_code ec;
|
||||
m_socks5_sock.close(ec);
|
||||
|
@ -461,7 +461,7 @@ void udp_socket::on_name_lookup(error_code const& e, tcp::resolver::iterator i)
|
|||
if (e) return;
|
||||
CHECK_MAGIC;
|
||||
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
|
||||
m_proxy_addr.address(i->endpoint().address());
|
||||
m_proxy_addr.port(i->endpoint().port());
|
||||
|
@ -473,7 +473,7 @@ void udp_socket::on_name_lookup(error_code const& e, tcp::resolver::iterator i)
|
|||
void udp_socket::on_timeout()
|
||||
{
|
||||
CHECK_MAGIC;
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
|
||||
error_code ec;
|
||||
m_socks5_sock.close(ec);
|
||||
|
@ -483,7 +483,7 @@ void udp_socket::on_timeout()
|
|||
void udp_socket::on_connect(int ticket)
|
||||
{
|
||||
CHECK_MAGIC;
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
|
||||
m_connection_ticket = ticket;
|
||||
error_code ec;
|
||||
|
@ -496,7 +496,7 @@ void udp_socket::on_connected(error_code const& e)
|
|||
{
|
||||
CHECK_MAGIC;
|
||||
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
m_cc.done(m_connection_ticket);
|
||||
m_connection_ticket = -1;
|
||||
if (e) return;
|
||||
|
@ -527,7 +527,7 @@ void udp_socket::handshake1(error_code const& e)
|
|||
CHECK_MAGIC;
|
||||
if (e) return;
|
||||
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
|
||||
asio::async_read(m_socks5_sock, asio::buffer(m_tmp_buf, 2)
|
||||
, boost::bind(&udp_socket::handshake2, this, _1));
|
||||
|
@ -540,7 +540,7 @@ void udp_socket::handshake2(error_code const& e)
|
|||
|
||||
using namespace libtorrent::detail;
|
||||
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
|
||||
char* p = &m_tmp_buf[0];
|
||||
int version = read_uint8(p);
|
||||
|
@ -584,7 +584,7 @@ void udp_socket::handshake3(error_code const& e)
|
|||
CHECK_MAGIC;
|
||||
if (e) return;
|
||||
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
|
||||
asio::async_read(m_socks5_sock, asio::buffer(m_tmp_buf, 2)
|
||||
, boost::bind(&udp_socket::handshake4, this, _1));
|
||||
|
@ -595,7 +595,7 @@ void udp_socket::handshake4(error_code const& e)
|
|||
CHECK_MAGIC;
|
||||
if (e) return;
|
||||
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
|
||||
using namespace libtorrent::detail;
|
||||
|
||||
|
@ -614,7 +614,7 @@ void udp_socket::socks_forward_udp()
|
|||
CHECK_MAGIC;
|
||||
using namespace libtorrent::detail;
|
||||
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
|
||||
// send SOCKS5 UDP command
|
||||
char* p = &m_tmp_buf[0];
|
||||
|
@ -634,7 +634,7 @@ void udp_socket::connect1(error_code const& e)
|
|||
CHECK_MAGIC;
|
||||
if (e) return;
|
||||
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
|
||||
asio::async_read(m_socks5_sock, asio::buffer(m_tmp_buf, 10)
|
||||
, boost::bind(&udp_socket::connect2, this, _1));
|
||||
|
@ -645,7 +645,7 @@ void udp_socket::connect2(error_code const& e)
|
|||
CHECK_MAGIC;
|
||||
if (e) return;
|
||||
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
|
||||
using namespace libtorrent::detail;
|
||||
|
||||
|
|
39
src/upnp.cpp
39
src/upnp.cpp
|
@ -51,7 +51,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <boost/asio/ip/host_name.hpp>
|
||||
#include <boost/asio/ip/multicast.hpp>
|
||||
#endif
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <cstdlib>
|
||||
|
||||
using boost::bind;
|
||||
|
@ -106,21 +105,21 @@ upnp::~upnp()
|
|||
|
||||
void upnp::discover_device()
|
||||
{
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
if (m_socket.num_send_sockets() == 0)
|
||||
log("No network interfaces to broadcast to", l);
|
||||
|
||||
discover_device_impl(l);
|
||||
}
|
||||
|
||||
void upnp::log(char const* msg, mutex_t::scoped_lock& l)
|
||||
void upnp::log(char const* msg, mutex::scoped_lock& l)
|
||||
{
|
||||
l.unlock();
|
||||
m_log_callback(msg);
|
||||
l.lock();
|
||||
}
|
||||
|
||||
void upnp::discover_device_impl(mutex_t::scoped_lock& l)
|
||||
void upnp::discover_device_impl(mutex::scoped_lock& l)
|
||||
{
|
||||
const char msearch[] =
|
||||
"M-SEARCH * HTTP/1.1\r\n"
|
||||
|
@ -157,7 +156,7 @@ void upnp::discover_device_impl(mutex_t::scoped_lock& l)
|
|||
// returns a reference to a mapping or -1 on failure
|
||||
int upnp::add_mapping(upnp::protocol_type p, int external_port, int local_port)
|
||||
{
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
|
||||
char msg[200];
|
||||
snprintf(msg, sizeof(msg), "adding port map: [ protocol: %s ext_port: %u "
|
||||
|
@ -205,7 +204,7 @@ int upnp::add_mapping(upnp::protocol_type p, int external_port, int local_port)
|
|||
|
||||
void upnp::delete_mapping(int mapping)
|
||||
{
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
|
||||
if (mapping >= int(m_mappings.size())) return;
|
||||
|
||||
|
@ -250,7 +249,7 @@ void upnp::resend_request(error_code const& e)
|
|||
|
||||
boost::intrusive_ptr<upnp> me(self());
|
||||
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
|
||||
if (m_closing) return;
|
||||
|
||||
|
@ -308,7 +307,7 @@ void upnp::on_reply(udp::endpoint const& from, char* buffer
|
|||
{
|
||||
boost::intrusive_ptr<upnp> me(self());
|
||||
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
|
||||
using namespace libtorrent::detail;
|
||||
|
||||
|
@ -569,7 +568,7 @@ void upnp::on_reply(udp::endpoint const& from, char* buffer
|
|||
}
|
||||
|
||||
void upnp::post(upnp::rootdevice const& d, char const* soap
|
||||
, char const* soap_action, mutex_t::scoped_lock& l)
|
||||
, char const* soap_action, mutex::scoped_lock& l)
|
||||
{
|
||||
TORRENT_ASSERT(d.magic == 1337);
|
||||
TORRENT_ASSERT(d.upnp_connection);
|
||||
|
@ -594,7 +593,7 @@ void upnp::post(upnp::rootdevice const& d, char const* soap
|
|||
|
||||
void upnp::create_port_mapping(http_connection& c, rootdevice& d, int i)
|
||||
{
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
|
||||
TORRENT_ASSERT(d.magic == 1337);
|
||||
|
||||
|
@ -636,7 +635,7 @@ void upnp::create_port_mapping(http_connection& c, rootdevice& d, int i)
|
|||
post(d, soap, soap_action, l);
|
||||
}
|
||||
|
||||
void upnp::next(rootdevice& d, int i, mutex_t::scoped_lock& l)
|
||||
void upnp::next(rootdevice& d, int i, mutex::scoped_lock& l)
|
||||
{
|
||||
if (i < num_mappings() - 1)
|
||||
{
|
||||
|
@ -653,7 +652,7 @@ void upnp::next(rootdevice& d, int i, mutex_t::scoped_lock& l)
|
|||
}
|
||||
}
|
||||
|
||||
void upnp::update_map(rootdevice& d, int i, mutex_t::scoped_lock& l)
|
||||
void upnp::update_map(rootdevice& d, int i, mutex::scoped_lock& l)
|
||||
{
|
||||
TORRENT_ASSERT(d.magic == 1337);
|
||||
TORRENT_ASSERT(i < int(d.mapping.size()));
|
||||
|
@ -717,7 +716,7 @@ void upnp::update_map(rootdevice& d, int i, mutex_t::scoped_lock& l)
|
|||
|
||||
void upnp::delete_port_mapping(rootdevice& d, int i)
|
||||
{
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
|
||||
TORRENT_ASSERT(d.magic == 1337);
|
||||
|
||||
|
@ -837,7 +836,7 @@ void upnp::on_upnp_xml(error_code const& e
|
|||
{
|
||||
boost::intrusive_ptr<upnp> me(self());
|
||||
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
|
||||
TORRENT_ASSERT(d.magic == 1337);
|
||||
if (d.upnp_connection && d.upnp_connection.get() == &c)
|
||||
|
@ -953,7 +952,7 @@ void upnp::on_upnp_xml(error_code const& e
|
|||
if (num_mappings() > 0) update_map(d, 0, l);
|
||||
}
|
||||
|
||||
void upnp::disable(error_code const& ec, mutex_t::scoped_lock& l)
|
||||
void upnp::disable(error_code const& ec, mutex::scoped_lock& l)
|
||||
{
|
||||
m_disabled = true;
|
||||
|
||||
|
@ -1070,7 +1069,7 @@ void upnp::on_upnp_map_response(error_code const& e
|
|||
{
|
||||
boost::intrusive_ptr<upnp> me(self());
|
||||
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
|
||||
TORRENT_ASSERT(d.magic == 1337);
|
||||
if (d.upnp_connection && d.upnp_connection.get() == &c)
|
||||
|
@ -1203,7 +1202,7 @@ void upnp::on_upnp_map_response(error_code const& e
|
|||
next(d, mapping, l);
|
||||
}
|
||||
|
||||
void upnp::return_error(int mapping, int code, mutex_t::scoped_lock& l)
|
||||
void upnp::return_error(int mapping, int code, mutex::scoped_lock& l)
|
||||
{
|
||||
int num_errors = sizeof(error_codes) / sizeof(error_codes[0]);
|
||||
error_code_t* end = error_codes + num_errors;
|
||||
|
@ -1228,7 +1227,7 @@ void upnp::on_upnp_unmap_response(error_code const& e
|
|||
{
|
||||
boost::intrusive_ptr<upnp> me(self());
|
||||
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
|
||||
TORRENT_ASSERT(d.magic == 1337);
|
||||
if (d.upnp_connection && d.upnp_connection.get() == &c)
|
||||
|
@ -1273,7 +1272,7 @@ void upnp::on_expire(error_code const& e)
|
|||
ptime now = time_now();
|
||||
ptime next_expire = max_time();
|
||||
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
|
||||
for (std::set<rootdevice>::iterator i = m_devices.begin()
|
||||
, end(m_devices.end()); i != end; ++i)
|
||||
|
@ -1306,7 +1305,7 @@ void upnp::on_expire(error_code const& e)
|
|||
|
||||
void upnp::close()
|
||||
{
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
|
||||
error_code ec;
|
||||
m_refresh_timer.cancel(ec);
|
||||
|
|
|
@ -101,18 +101,7 @@ bool print_alerts(libtorrent::session& ses, char const* name
|
|||
|
||||
void test_sleep(int millisec)
|
||||
{
|
||||
boost::xtime xt;
|
||||
boost::xtime_get(&xt, boost::TIME_UTC);
|
||||
boost::uint64_t nanosec = (millisec % 1000) * 1000000 + xt.nsec;
|
||||
int sec = millisec / 1000;
|
||||
if (nanosec > 1000000000)
|
||||
{
|
||||
nanosec -= 1000000000;
|
||||
sec++;
|
||||
}
|
||||
xt.nsec = nanosec;
|
||||
xt.sec += sec;
|
||||
boost::thread::sleep(xt);
|
||||
libtorrent::sleep(millisec);
|
||||
}
|
||||
|
||||
void stop_web_server(int port)
|
||||
|
|
|
@ -37,11 +37,11 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/alert_types.hpp"
|
||||
#include "libtorrent/aux_/session_impl.hpp"
|
||||
#include "libtorrent/create_torrent.hpp"
|
||||
#include "libtorrent/thread.hpp"
|
||||
|
||||
#include <boost/utility.hpp>
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <boost/filesystem/convenience.hpp>
|
||||
#include <boost/thread/mutex.hpp>
|
||||
|
||||
#include "test.hpp"
|
||||
#include "setup_transfer.hpp"
|
||||
|
@ -148,8 +148,7 @@ struct test_storage : storage_interface
|
|||
{
|
||||
if (slot == 0 || slot == 5999)
|
||||
{
|
||||
boost::thread::sleep(boost::get_system_time()
|
||||
+ boost::posix_time::seconds(2));
|
||||
sleep(2000);
|
||||
std::cerr << "--- starting ---\n" << std::endl;
|
||||
}
|
||||
return size;
|
||||
|
@ -363,7 +362,7 @@ void run_storage_tests(boost::intrusive_ptr<torrent_info> info
|
|||
boost::shared_ptr<int> dummy(new int);
|
||||
boost::intrusive_ptr<piece_manager> pm = new piece_manager(dummy, info
|
||||
, test_path, fp, io, default_storage_constructor, storage_mode);
|
||||
boost::mutex lock;
|
||||
mutex lock;
|
||||
|
||||
error_code ec;
|
||||
bool done = false;
|
||||
|
@ -564,7 +563,7 @@ void test_check_files(path const& test_path
|
|||
boost::shared_ptr<int> dummy(new int);
|
||||
boost::intrusive_ptr<piece_manager> pm = new piece_manager(dummy, info
|
||||
, test_path, fp, io, default_storage_constructor, storage_mode);
|
||||
boost::mutex lock;
|
||||
mutex lock;
|
||||
|
||||
error_code ec;
|
||||
bool done = false;
|
||||
|
|
Loading…
Reference in New Issue