added resolver_cache_timeout setting (#1878)
added resolver_cache_timeout setting
This commit is contained in:
parent
7c35c2270f
commit
45bea967c2
|
@ -1,3 +1,4 @@
|
||||||
|
* added resolver_cache_timeout setting for internal host name resolver
|
||||||
* make parse_magnet_uri take a string_view instead of std::string
|
* make parse_magnet_uri take a string_view instead of std::string
|
||||||
* deprecate add_torrent_params::url field. use parse_magnet_uri instead
|
* deprecate add_torrent_params::url field. use parse_magnet_uri instead
|
||||||
* optimize download queue management
|
* optimize download queue management
|
||||||
|
|
|
@ -704,6 +704,7 @@ namespace libtorrent
|
||||||
void update_auto_sequential();
|
void update_auto_sequential();
|
||||||
void update_max_failcount();
|
void update_max_failcount();
|
||||||
void update_close_file_interval();
|
void update_close_file_interval();
|
||||||
|
void update_resolver_cache_timeout();
|
||||||
|
|
||||||
void update_upnp();
|
void update_upnp();
|
||||||
void update_natpmp();
|
void update_natpmp();
|
||||||
|
|
|
@ -45,7 +45,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/socket.hpp"
|
#include "libtorrent/socket.hpp"
|
||||||
#include "libtorrent/resolver_interface.hpp"
|
#include "libtorrent/resolver_interface.hpp"
|
||||||
#include "libtorrent/address.hpp"
|
#include "libtorrent/address.hpp"
|
||||||
#include "libtorrent/time.hpp"
|
|
||||||
|
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
|
@ -59,6 +58,8 @@ struct TORRENT_EXTRA_EXPORT resolver final : resolver_interface
|
||||||
|
|
||||||
virtual void abort() override;
|
virtual void abort() override;
|
||||||
|
|
||||||
|
virtual void set_cache_timeout(seconds timeout) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void on_lookup(error_code const& ec, tcp::resolver::iterator i
|
void on_lookup(error_code const& ec, tcp::resolver::iterator i
|
||||||
|
|
|
@ -38,6 +38,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include "libtorrent/error_code.hpp"
|
#include "libtorrent/error_code.hpp"
|
||||||
#include "libtorrent/address.hpp"
|
#include "libtorrent/address.hpp"
|
||||||
|
#include "libtorrent/time.hpp"
|
||||||
|
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
|
@ -62,6 +63,9 @@ struct TORRENT_EXTRA_EXPORT resolver_interface
|
||||||
, callback_t const& h) = 0;
|
, callback_t const& h) = 0;
|
||||||
|
|
||||||
virtual void abort() = 0;
|
virtual void abort() = 0;
|
||||||
|
|
||||||
|
virtual void set_cache_timeout(seconds timeout) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
~resolver_interface() {}
|
~resolver_interface() {}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1632,6 +1632,11 @@ namespace libtorrent
|
||||||
// given time.
|
// given time.
|
||||||
max_web_seed_connections,
|
max_web_seed_connections,
|
||||||
|
|
||||||
|
// the number of seconds before the internal host name resolver
|
||||||
|
// considers a cache value timed out, negative values are interpreted
|
||||||
|
// as zero.
|
||||||
|
resolver_cache_timeout,
|
||||||
|
|
||||||
max_int_setting_internal
|
max_int_setting_internal
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -132,4 +132,12 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
m_resolver.cancel();
|
m_resolver.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void resolver::set_cache_timeout(seconds timeout)
|
||||||
|
{
|
||||||
|
if (timeout >= seconds(0))
|
||||||
|
m_timeout = timeout;
|
||||||
|
else
|
||||||
|
m_timeout = seconds(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -625,6 +625,7 @@ namespace aux {
|
||||||
update_connections_limit();
|
update_connections_limit();
|
||||||
update_unchoke_limit();
|
update_unchoke_limit();
|
||||||
update_disk_threads();
|
update_disk_threads();
|
||||||
|
update_resolver_cache_timeout();
|
||||||
update_upnp();
|
update_upnp();
|
||||||
update_natpmp();
|
update_natpmp();
|
||||||
update_lsd();
|
update_lsd();
|
||||||
|
@ -5087,6 +5088,12 @@ namespace aux {
|
||||||
m_close_file_timer.async_wait(make_tick_handler(std::bind(&session_impl::on_close_file, this, _1)));
|
m_close_file_timer.async_wait(make_tick_handler(std::bind(&session_impl::on_close_file, this, _1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void session_impl::update_resolver_cache_timeout()
|
||||||
|
{
|
||||||
|
int const timeout = m_settings.get_int(settings_pack::resolver_cache_timeout);
|
||||||
|
m_host_resolver.set_cache_timeout(seconds(timeout));
|
||||||
|
}
|
||||||
|
|
||||||
void session_impl::update_proxy()
|
void session_impl::update_proxy()
|
||||||
{
|
{
|
||||||
for (auto& i : m_listen_sockets)
|
for (auto& i : m_listen_sockets)
|
||||||
|
|
|
@ -335,6 +335,7 @@ namespace libtorrent
|
||||||
SET(web_seed_name_lookup_retry, 1800, nullptr),
|
SET(web_seed_name_lookup_retry, 1800, nullptr),
|
||||||
SET(close_file_interval, CLOSE_FILE_INTERVAL, &session_impl::update_close_file_interval),
|
SET(close_file_interval, CLOSE_FILE_INTERVAL, &session_impl::update_close_file_interval),
|
||||||
SET(max_web_seed_connections, 3, nullptr),
|
SET(max_web_seed_connections, 3, nullptr),
|
||||||
|
SET(resolver_cache_timeout, 1200, &session_impl::update_resolver_cache_timeout),
|
||||||
}});
|
}});
|
||||||
|
|
||||||
#undef SET
|
#undef SET
|
||||||
|
|
|
@ -58,6 +58,7 @@ TORRENT_TEST(session)
|
||||||
settings_pack sett = settings();
|
settings_pack sett = settings();
|
||||||
sett.set_int(settings_pack::num_optimistic_unchoke_slots, 10);
|
sett.set_int(settings_pack::num_optimistic_unchoke_slots, 10);
|
||||||
sett.set_int(settings_pack::unchoke_slots_limit, 10);
|
sett.set_int(settings_pack::unchoke_slots_limit, 10);
|
||||||
|
sett.set_int(settings_pack::resolver_cache_timeout, 1000);
|
||||||
|
|
||||||
ses.apply_settings(sett);
|
ses.apply_settings(sett);
|
||||||
|
|
||||||
|
@ -90,6 +91,11 @@ TORRENT_TEST(session)
|
||||||
ses.apply_settings(sett);
|
ses.apply_settings(sett);
|
||||||
TEST_CHECK(ses.get_settings().get_int(settings_pack::unchoke_slots_limit) == 8);
|
TEST_CHECK(ses.get_settings().get_int(settings_pack::unchoke_slots_limit) == 8);
|
||||||
|
|
||||||
|
TEST_EQUAL(ses.get_settings().get_int(settings_pack::resolver_cache_timeout), 1000);
|
||||||
|
sett.set_int(settings_pack::resolver_cache_timeout, 1001);
|
||||||
|
ses.apply_settings(sett);
|
||||||
|
TEST_EQUAL(ses.get_settings().get_int(settings_pack::resolver_cache_timeout), 1001);
|
||||||
|
|
||||||
// make sure the destructor waits properly
|
// make sure the destructor waits properly
|
||||||
// for the asynchronous call to set the alert
|
// for the asynchronous call to set the alert
|
||||||
// mask completes, before it goes on to destruct
|
// mask completes, before it goes on to destruct
|
||||||
|
|
|
@ -253,5 +253,7 @@ TORRENT_TEST(settings_pack_abi)
|
||||||
TEST_EQUAL(settings_pack::aio_threads, settings_pack::int_type_base + 104);
|
TEST_EQUAL(settings_pack::aio_threads, settings_pack::int_type_base + 104);
|
||||||
TEST_EQUAL(settings_pack::max_http_recv_buffer_size, settings_pack::int_type_base + 115);
|
TEST_EQUAL(settings_pack::max_http_recv_buffer_size, settings_pack::int_type_base + 115);
|
||||||
TEST_EQUAL(settings_pack::web_seed_name_lookup_retry, settings_pack::int_type_base + 128);
|
TEST_EQUAL(settings_pack::web_seed_name_lookup_retry, settings_pack::int_type_base + 128);
|
||||||
|
TEST_EQUAL(settings_pack::close_file_interval, settings_pack::int_type_base + 129);
|
||||||
|
TEST_EQUAL(settings_pack::max_web_seed_connections, settings_pack::int_type_base + 130);
|
||||||
|
TEST_EQUAL(settings_pack::resolver_cache_timeout, settings_pack::int_type_base + 131);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue