forked from premiere/premiere-libtorrent
fix bug where settings_pack::file_pool_size setting was not being honored
This commit is contained in:
parent
faa2029f8b
commit
5cb12318c5
|
@ -1,3 +1,4 @@
|
|||
* fix bug where settings_pack::file_pool_size setting was not being honored
|
||||
* add feature to periodically close files (to make windows clear disk cache)
|
||||
* fix bug in torrent_handle::file_status
|
||||
* fix issue with peers not updated on metadata from magnet links
|
||||
|
|
|
@ -786,9 +786,7 @@ namespace libtorrent
|
|||
// for viruses. deferring the closing of the files will be the
|
||||
// difference between a usable system and a completely hogged down
|
||||
// system. Most operating systems also has a limit on the total number
|
||||
// of file descriptors a process may have open. It is usually a good
|
||||
// idea to find this limit and set the number of connections and the
|
||||
// number of files limits so their sum is slightly below it.
|
||||
// of file descriptors a process may have open.
|
||||
file_pool_size,
|
||||
|
||||
// ``max_failcount`` is the maximum times we try to connect to a peer
|
||||
|
|
|
@ -38,6 +38,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/session.hpp"
|
||||
#include "libtorrent/session_stats.hpp"
|
||||
#include "libtorrent/file.hpp"
|
||||
#include "libtorrent/torrent_info.hpp"
|
||||
|
||||
using namespace libtorrent;
|
||||
|
||||
|
@ -84,3 +85,55 @@ TORRENT_TEST(close_file_interval)
|
|||
TEST_CHECK(ran_to_completion);
|
||||
}
|
||||
|
||||
TORRENT_TEST(file_pool_size)
|
||||
{
|
||||
bool ran_to_completion = false;
|
||||
int max_files = 0;
|
||||
|
||||
setup_swarm(2, swarm_test::download
|
||||
// add session
|
||||
, [](lt::settings_pack& pack)
|
||||
{
|
||||
pack.set_int(lt::settings_pack::file_pool_size, 5);
|
||||
}
|
||||
// add torrent
|
||||
, [](lt::add_torrent_params& atp) {
|
||||
// we need a torrent with lots of files in it, to hit the
|
||||
// file_size_limit we set.
|
||||
file_storage fs;
|
||||
for (int i = 0; i < 0x10 * 9; ++i)
|
||||
{
|
||||
char filename[50];
|
||||
snprintf(filename, sizeof(filename), "root/file-%d", i);
|
||||
fs.add_file(filename, 0x400);
|
||||
}
|
||||
atp.ti = boost::make_shared<torrent_info>(*atp.ti);
|
||||
atp.ti->remap_files(fs);
|
||||
}
|
||||
// on alert
|
||||
, [&](lt::alert const* a, lt::session&)
|
||||
{}
|
||||
// terminate
|
||||
, [&](int ticks, lt::session& ses) -> bool
|
||||
{
|
||||
if (ticks > 80)
|
||||
{
|
||||
TEST_ERROR("timeout");
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<pool_file_status> status;
|
||||
ses.get_torrents().at(0).file_status(status);
|
||||
printf("open files: %d\n", int(status.size()));
|
||||
max_files = std::max(max_files, int(status.size()));
|
||||
if (!is_seed(ses)) return false;
|
||||
printf("completed in %d ticks\n", ticks);
|
||||
ran_to_completion = true;
|
||||
return true;
|
||||
});
|
||||
|
||||
TEST_CHECK(max_files <= 5);
|
||||
TEST_CHECK(max_files >= 4);
|
||||
TEST_CHECK(ran_to_completion);
|
||||
}
|
||||
|
||||
|
|
|
@ -57,10 +57,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include "libtorrent/debug.hpp"
|
||||
|
||||
#if TORRENT_USE_RLIMIT
|
||||
#include <sys/resource.h>
|
||||
#endif
|
||||
|
||||
#define DEBUG_DISK_THREAD 0
|
||||
|
||||
#if __cplusplus >= 201103L || defined __clang__
|
||||
|
@ -172,7 +168,7 @@ namespace libtorrent
|
|||
// futexes, shared objects etc.
|
||||
// 80% of the available file descriptors should go to connections
|
||||
// 20% goes towards regular files
|
||||
const int max_files = (std::min)((std::max)(5
|
||||
const int max_files = std::min((std::max)(5
|
||||
, (max_open_files() - 20) * 2 / 10)
|
||||
, m_file_pool.size_limit());
|
||||
m_file_pool.resize(max_files);
|
||||
|
@ -282,6 +278,7 @@ namespace libtorrent
|
|||
apply_pack(pack, m_settings);
|
||||
error_code ec;
|
||||
m_disk_cache.set_settings(m_settings, ec);
|
||||
m_file_pool.resize(m_settings.get_int(settings_pack::file_pool_size));
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
if (ec && alerts.should_post<mmap_cache_alert>())
|
||||
{
|
||||
|
|
|
@ -57,24 +57,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <valgrind/memcheck.h>
|
||||
#endif
|
||||
|
||||
#if TORRENT_USE_RLIMIT
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wlong-long"
|
||||
#endif // __GNUC__
|
||||
|
||||
#include <sys/resource.h>
|
||||
|
||||
// capture this here where warnings are disabled (the macro generates warnings)
|
||||
const rlim_t rlim_infinity = RLIM_INFINITY;
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif // __GNUC__
|
||||
|
||||
#endif // TORRENT_USE_RLIMIT
|
||||
|
||||
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
||||
|
||||
#include "libtorrent/aux_/openssl.hpp"
|
||||
|
|
Loading…
Reference in New Issue