fix issue with initializing settings on session construction
This commit is contained in:
parent
f42b63c7ea
commit
4b467f82ac
|
@ -1,4 +1,5 @@
|
|||
|
||||
* fix issue with initializing settings on session construction
|
||||
* fix issue with receiving interested before metadata
|
||||
* fix IPv6 tracker announce issue
|
||||
* restore path sanitization behavior of ":"
|
||||
|
|
|
@ -182,10 +182,10 @@ namespace libtorrent
|
|||
typedef std::map<sha1_hash, boost::shared_ptr<torrent> > torrent_map;
|
||||
#endif
|
||||
|
||||
session_impl(io_service& ios);
|
||||
session_impl(io_service& ios, settings_pack const& pack);
|
||||
virtual ~session_impl();
|
||||
|
||||
void start_session(settings_pack const& pack);
|
||||
void start_session();
|
||||
|
||||
void set_load_function(user_load_function_t fun)
|
||||
{ m_user_load_torrent = fun; }
|
||||
|
@ -620,6 +620,9 @@ namespace libtorrent
|
|||
{ return &m_utp_socket_manager; }
|
||||
void inc_boost_connections() TORRENT_OVERRIDE { ++m_boost_connections; }
|
||||
|
||||
// the settings for the client
|
||||
aux::session_settings m_settings;
|
||||
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
// the time when the next rss feed needs updating
|
||||
time_point m_next_rss_update;
|
||||
|
@ -684,7 +687,7 @@ namespace libtorrent
|
|||
|
||||
peer_class_pool m_classes;
|
||||
|
||||
void init(boost::shared_ptr<settings_pack> pack);
|
||||
void init();
|
||||
|
||||
void submit_disk_jobs();
|
||||
|
||||
|
@ -693,9 +696,6 @@ namespace libtorrent
|
|||
void on_lsd_peer(tcp::endpoint peer, sha1_hash const& ih);
|
||||
void setup_socket_buffers(socket_type& s) TORRENT_OVERRIDE;
|
||||
|
||||
// the settings for the client
|
||||
aux::session_settings m_settings;
|
||||
|
||||
counters m_stats_counters;
|
||||
|
||||
// this is a pool allocator for torrent_peer objects
|
||||
|
|
|
@ -42,6 +42,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
namespace libtorrent
|
||||
{
|
||||
struct settings_pack;
|
||||
TORRENT_EXTRA_EXPORT void initialize_default_settings(aux::session_settings& s);
|
||||
}
|
||||
|
||||
|
@ -71,6 +72,7 @@ namespace libtorrent { namespace aux
|
|||
bool get_bool(int name) const { GET(bool, false); }
|
||||
|
||||
session_settings();
|
||||
session_settings(settings_pack const&);
|
||||
|
||||
private:
|
||||
std::string m_strings[settings_pack::num_string_settings];
|
||||
|
|
|
@ -66,6 +66,7 @@ namespace libtorrent
|
|||
TORRENT_EXTRA_EXPORT boost::shared_ptr<settings_pack> load_pack_from_dict(bdecode_node const& settings);
|
||||
TORRENT_EXTRA_EXPORT void save_settings_to_dict(aux::session_settings const& s, entry::dictionary_type& sett);
|
||||
TORRENT_EXTRA_EXPORT void apply_pack(settings_pack const* pack, aux::session_settings& sett, aux::session_impl* ses = 0);
|
||||
TORRENT_EXTRA_EXPORT void run_all_updates(aux::session_impl& ses);
|
||||
|
||||
TORRENT_EXPORT int setting_by_name(std::string const& name);
|
||||
TORRENT_EXPORT char const* name_for_setting(int s);
|
||||
|
|
|
@ -347,7 +347,7 @@ namespace libtorrent
|
|||
ios = m_io_service.get();
|
||||
}
|
||||
|
||||
m_impl = boost::make_shared<session_impl>(boost::ref(*ios));
|
||||
m_impl = boost::make_shared<session_impl>(boost::ref(*ios), boost::ref(pack));
|
||||
*static_cast<session_handle*>(this) = session_handle(m_impl.get());
|
||||
|
||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||
|
@ -361,7 +361,7 @@ namespace libtorrent
|
|||
TORRENT_UNUSED(flags);
|
||||
#endif
|
||||
|
||||
m_impl->start_session(pack);
|
||||
m_impl->start_session();
|
||||
|
||||
if (internal_executor)
|
||||
{
|
||||
|
|
|
@ -336,21 +336,20 @@ namespace aux {
|
|||
} // anonymous namesoace
|
||||
#endif
|
||||
|
||||
session_impl::session_impl(io_service& ios)
|
||||
:
|
||||
session_impl::session_impl(io_service& ios, settings_pack const& pack)
|
||||
: m_settings(pack)
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
m_next_rss_update(min_time())
|
||||
,
|
||||
, m_next_rss_update(min_time())
|
||||
#endif
|
||||
#ifndef TORRENT_DISABLE_POOL_ALLOCATOR
|
||||
m_send_buffers(send_buffer_size())
|
||||
,
|
||||
, m_send_buffers(send_buffer_size())
|
||||
#endif
|
||||
m_io_service(ios)
|
||||
, m_io_service(ios)
|
||||
#ifdef TORRENT_USE_OPENSSL
|
||||
, m_ssl_ctx(m_io_service, boost::asio::ssl::context::sslv23)
|
||||
#endif
|
||||
, m_alerts(m_settings.get_int(settings_pack::alert_queue_size), alert::all_categories)
|
||||
, m_alerts(m_settings.get_int(settings_pack::alert_queue_size)
|
||||
, m_settings.get_int(settings_pack::alert_mask))
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
, m_alert_pointer_pos(0)
|
||||
#endif
|
||||
|
@ -448,19 +447,15 @@ namespace aux {
|
|||
TORRENT_ASSERT_VAL(!ec, ec);
|
||||
|
||||
update_time_now();
|
||||
m_disk_thread.set_settings(&pack, m_alerts);
|
||||
}
|
||||
|
||||
// This function is called by the creating thread, not in the message loop's
|
||||
// / io_service thread.
|
||||
// TODO: 2 is there a reason not to move all of this into init()? and just
|
||||
// post it to the io_service?
|
||||
void session_impl::start_session(settings_pack const& pack)
|
||||
void session_impl::start_session()
|
||||
{
|
||||
if (pack.has_val(settings_pack::alert_mask))
|
||||
{
|
||||
m_alerts.set_alert_mask(pack.get_int(settings_pack::alert_mask));
|
||||
}
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
session_log("start session");
|
||||
#endif
|
||||
|
@ -540,13 +535,11 @@ namespace aux {
|
|||
session_log(" generated peer ID: %s", m_peer_id.to_string().c_str());
|
||||
#endif
|
||||
|
||||
boost::shared_ptr<settings_pack> copy = boost::make_shared<settings_pack>(pack);
|
||||
m_io_service.post(boost::bind(&session_impl::init, this, copy));
|
||||
m_io_service.post(boost::bind(&session_impl::init, this));
|
||||
}
|
||||
|
||||
void session_impl::init(boost::shared_ptr<settings_pack> pack)
|
||||
void session_impl::init()
|
||||
{
|
||||
INVARIANT_CHECK;
|
||||
// this is a debug facility
|
||||
// see single_threaded in debug.hpp
|
||||
thread_started();
|
||||
|
@ -604,32 +597,20 @@ namespace aux {
|
|||
session_log(" done starting session");
|
||||
#endif
|
||||
|
||||
apply_settings_pack(pack);
|
||||
// apply all m_settings to this session
|
||||
run_all_updates(*this);
|
||||
|
||||
// call update_* after settings set initialized
|
||||
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
update_local_download_rate();
|
||||
update_local_upload_rate();
|
||||
#endif
|
||||
update_download_rate();
|
||||
update_upload_rate();
|
||||
update_connections_limit();
|
||||
update_unchoke_limit();
|
||||
update_disk_threads();
|
||||
update_network_threads();
|
||||
update_upnp();
|
||||
update_natpmp();
|
||||
update_lsd();
|
||||
update_dht();
|
||||
update_peer_fingerprint();
|
||||
update_dht_bootstrap_nodes();
|
||||
// this applies unchoke settings from m_settings
|
||||
recalculate_unchoke_slots();
|
||||
|
||||
if (m_listen_sockets.empty())
|
||||
{
|
||||
update_listen_interfaces();
|
||||
open_listen_port();
|
||||
}
|
||||
#if TORRENT_USE_INVARIANT_CHECKS
|
||||
check_invariant();
|
||||
#endif
|
||||
}
|
||||
|
||||
void session_impl::async_resolve(std::string const& host, int flags
|
||||
|
@ -4191,7 +4172,6 @@ retry:
|
|||
void session_impl::recalculate_unchoke_slots()
|
||||
{
|
||||
TORRENT_ASSERT(is_single_thread());
|
||||
INVARIANT_CHECK;
|
||||
|
||||
time_point const now = aux::time_now();
|
||||
time_duration const unchoke_interval = now - m_last_choke;
|
||||
|
@ -6309,7 +6289,7 @@ retry:
|
|||
|
||||
void session_impl::update_queued_disk_bytes()
|
||||
{
|
||||
boost::uint64_t cache_size = m_settings.get_int(settings_pack::cache_size);
|
||||
boost::uint64_t const cache_size = m_settings.get_int(settings_pack::cache_size);
|
||||
if (m_settings.get_int(settings_pack::max_queued_disk_bytes) / 16 / 1024
|
||||
> cache_size / 2
|
||||
&& cache_size > 5
|
||||
|
@ -7179,7 +7159,6 @@ retry:
|
|||
#else
|
||||
std::set<peer_connection*> unique_peers;
|
||||
#endif
|
||||
TORRENT_ASSERT(m_settings.get_int(settings_pack::connections_limit) > 0);
|
||||
|
||||
int unchokes = 0;
|
||||
int unchokes_all = 0;
|
||||
|
|
|
@ -31,6 +31,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
*/
|
||||
|
||||
#include "libtorrent/aux_/session_settings.hpp"
|
||||
#include "libtorrent/settings_pack.hpp"
|
||||
|
||||
namespace libtorrent { namespace aux
|
||||
{
|
||||
|
@ -38,5 +39,11 @@ namespace libtorrent { namespace aux
|
|||
{
|
||||
initialize_default_settings(*this);
|
||||
}
|
||||
|
||||
session_settings::session_settings(settings_pack const& p)
|
||||
{
|
||||
initialize_default_settings(*this);
|
||||
apply_pack(&p, *this);
|
||||
}
|
||||
} }
|
||||
|
||||
|
|
|
@ -471,6 +471,28 @@ namespace libtorrent
|
|||
}
|
||||
}
|
||||
|
||||
void run_all_updates(aux::session_impl& ses)
|
||||
{
|
||||
typedef void (aux::session_impl::*fun_t)();
|
||||
for (int i = 0; i < settings_pack::num_string_settings; ++i)
|
||||
{
|
||||
fun_t const& f = str_settings[i].fun;
|
||||
if (f) (ses.*f)();
|
||||
}
|
||||
|
||||
for (int i = 0; i < settings_pack::num_int_settings; ++i)
|
||||
{
|
||||
fun_t const& f = int_settings[i].fun;
|
||||
if (f) (ses.*f)();
|
||||
}
|
||||
|
||||
for (int i = 0; i < settings_pack::num_bool_settings; ++i)
|
||||
{
|
||||
fun_t const& f = bool_settings[i].fun;
|
||||
if (f) (ses.*f)();
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
|
||||
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
||||
|
|
Loading…
Reference in New Issue